[R] RGEOS ERROR

Michael Sumner mdsumner at gmail.com
Tue Sep 2 11:00:10 CEST 2014


I suspect you are seeing old code in rgeos. Please upgrade.  If you cannot
do that, try a few other things like

## since you obviously have raster loaded

projection(clip.extent) <- projection(WorldMap)

LSMap <- gIntersection(WorldMap, clip.extent, byid = TRUE)

Does that work? If not possibly

projection(clip.extent) <- as.character(NA)

projection(WorldMap) <- as.character(NA)

LSMap <- gIntersection(WorldMap, clip.extent, byid = TRUE)
I just cannot verify those because I am up to date.

Cheers, Mike

Here's what I can do with rgeos  0.3-6:

## please declare your environment btw

library(maptools)

library(raster)

library(rgeos)

data(wrld_simpl)

clip.extent <- as(extent(76.3700, 31.7439, 78.6541, 33.2653),
"SpatialPolygons")

## this works, albeit with a warning

amap <- gIntersection(wrld_simpl, clip.extent, byid = TRUE)

## this does also work

proj4string(clip.extent) <- CRS(proj4string(amap))

amap <- gIntersection(wrld_simpl, clip.extent, byid = TRUE)

sessionInfo()

R version 3.1.1 (2014-07-10)

Platform: x86_64-w64-mingw32/x64 (64-bit)


locale:

[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252

[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C

[5] LC_TIME=English_Australia.1252


attached base packages:

[1] stats     graphics  grDevices utils     datasets  compiler  methods

[8] base


other attached packages:

[1] rgeos_0.3-6     raster_2.2-31   maptools_0.8-30 sp_1.0-15


loaded via a namespace (and not attached):

[1] foreign_0.8-61  grid_3.1.1      lattice_0.20-29 tools_3.1.1


On 2 Sep 2014 16:09, "Girija Kalyani" <smileismystyl at gmail.com> wrote:

> working configuration:
> R-3.1.1
> WIN-64
> goal: want to perfrom ploygon clipping, giving bounding box values of my
> study area and extract the area from world map.
>  I followed:
>
> > clip.extent <- as(extent(76.3700, 31.7439, 78.6541, 33.2653),
> "SpatialPolygons")
>
> > proj4string(clip.extent) <- CRS(proj4string(WorldMap))> LSMap <-
> gIntersection(WorldMap, clip.extent, byid = TRUE)
>
> Error :
>
> In RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_not_poly,
> "rgeos_intersection") :
>   spgeom1 and spgeom2 have different proj4 strings
>
>
> Any help or assistance would be highly obliged
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list