Message-ID: <AANLkTikWdK5sHNVuHafChqUQgdUE81uM7gAGQ2moVW7Z@mail.gmail.com>
Date: 2010-10-28T20:23:04Z
From: Peter Larson
Subject: Why I can't install RGDAL after R 2.12.0 release?
In-Reply-To: <1C99CC51-68A6-4295-A209-A4CFBB438057@ecotoxicology.de>
Hello all,
I have a grid of points and a spatial polygon shape file. I want to
clip the grid so that I only have the point which lie within the
shapefile.
I tried the following code:
## create a grid onto which we will interpolate:
## first get the range in data
x.range <- c(37,50)
y.range <- c(29,38)
## now expand to a grid with 500 meter spacing:
grd <- expand.grid(x=seq(from=x.range[1], to=x.range[2], by=.01),
y=seq(from=y.range[1], to=y.range[2], by=.01) )
## convert to SpatialPixel class
coordinates(grd) <- ~ x+y
gridded(grd) <- TRUE
## Read in Shapefile
ccShapet=readShapePoly('IRQ_adm0') # here cbg00barncnty is an ArcGIS shapefile
## Clip
clip <- overlay(grd, ccShapet)
#Plot
plot(clip)
BUT it does not work. I just get a vector of number and NA's, but not
the clipped grid.
Any ideas?
Thanks
Pete