[R-sig-Geo] Unable to apply 'gIntersection' successfully
satishr
satish.regonda at gmail.com
Tue Jan 31 18:32:22 CET 2012
Hi, I am trying to calculate fraction of a polygon that is intersected by
another polygon. I have data in two shape files; the first file corresponds
to a rectangular grid with uniform intervals whereas the second file
corresponds to US climate divisions, which are polygons. The script worked
fine expect for one ploygon; please see the below message. It looks like
coordinates of a polygon are corrupted but I am not sure whether it is the
cause and if so how to fix it. Any feedback is greatly appreciated. Data
sets and excerpts of my script are below mentioned.
Thanks,
Satish
library(rgdal); library(rgeos)
grid=readOGR("C:/Temp","Gaussian_Poylgon_ExtendedCONUS")
climagdiv=readOGR("C:/Temp","US102ClimateDivisions")
iclimdiv=45
print(paste("Climate Division ",iclimdiv,sep=""))
int = gIntersects(climagdiv[iclimdiv,],grid,byid=TRUE)
vec = vector(mode="list", length=dim(int)[2])
for (i in seq(along=vec)) vec[[i]] =
try(gIntersection(climagdiv[iclimdiv,],grid[int[,i],], byid=TRUE))
Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, "rgeos_intersection")
:
TopologyException: found non-noded intersection between LINESTRING
(-91.043 32.5763, -90.964 32.5763) and LINESTRING (-90.964 32.5763, -91.035
32.5763) at -90.964 32.5763
Data sets:
1. Rectangular Grid
http://r-sig-geo.2731867.n2.nabble.com/file/n7240529/GaussianPolygonExtendedCONUS.zip
GaussianPolygonExtendedCONUS.zip
2. US 102 climate divisions
http://r-sig-geo.2731867.n2.nabble.com/file/n7240529/US102ClimateDivisions.zip
US102ClimateDivisions.zip
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Unable-to-apply-gIntersection-successfully-tp7240529p7240529.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list