[R-sig-Geo] Problem clipping SpatialPolygonDataFrame
Robert J. Hijmans
r.hijmans at gmail.com
Thu Apr 23 17:16:22 CEST 2015
Luciano,
The extent you are using to crop is the same as the extent of the
entire extent, so it does not surprise me that there is no change.
Here is an example that works:
library(raster)
library(rgeos)
g <- getData('GADM', country='ARG', level=1)
e <- extent(-63.6, -55.1, -32.8, -27.6)
x <- crop(g, e)
plot(g)
plot(x, add=TRUE, border='blue', lwd=2)
Robert
On Thu, Apr 23, 2015 at 7:36 AM, Luciano La Sala
<lucianolasala at yahoo.com.ar> wrote:
> Hello everyone,
>
> I have a SpatialPolygonsDataFrame for Argentina which I need to crop using a
> bounding box or any other method. I tried the following but the new map
> turns out to have the same exact extent as the original one:
>
> # Info on my Data Frame.
>
>> summary(arg.provinces)
> Object of class SpatialPolygonsDataFrame
> Coordinates:
> min max
> x -73.57778 -53.59183
> y -55.06153 -21.77855
> Is projected: FALSE
> proj4string :
> [+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0]
>
>> extent(arg.provinces)
> class : Extent
> xmin : -73.57778
> xmax : -53.59183
> ymin : -55.06153
> ymax : -21.77855
>
> # Trying to clip it
>
> out <- crop(arg.provinces, extent(-73.57778, -53.59183, -55.06153,
> -21.77855))
> plot(out)
>
>> extent(out)
> class : Extent
> xmin : -73.57778
> xmax : -53.59184
> ymin : -55.06153
> ymax : -21.77855
>
>
> Thank you very much in advance!
>
>
> --
> Luciano F. La Sala
> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
> Cátedra de Epidemiología
> Departamento de Biología, Bioquímica y Farmacia
> Universidad Nacional del Sur
> San Juan 670
> Bahía Blanca (8000)
> Argentina
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list