[R-sig-Geo] Unable to apply 'gIntersection' successfully

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Jan 31 19:18:38 CET 2012


Maybe this helps:

> y = readOGR("US102ClimateDivisions", "US102ClimateDivisions")
OGR data source with driver: ESRI Shapefile
Source: "US102ClimateDivisions", layer: "US102ClimateDivisions"
with 102 features and 5 fields
Feature type: wkbPolygon with 2 dimensions
> gIsValid(y)
[1] FALSE
Warning message:
In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Ring Self-intersection at or near point -121.807 44.7908
> which(!gIsValid(y, byid=TRUE))
 21  28  44  98 100
 22  29  45  99 101
Warning messages:
1: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Ring Self-intersection at or near point -121.807 44.7908
2: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Self-intersection at or near point -118.222 46.0004
3: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Self-intersection at or near point -91.035 32.5763
4: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Ring Self-intersection at or near point -73.834 40.5904
5: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Ring Self-intersection at or near point -69.3086 43.9069


On 01/31/2012 06:32 PM, satishr wrote:
> 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.
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list