Skip to content
Prev 18211 / 29559 Next

Error in reading .shp

On Tue, 7 May 2013, Danielle Rappaport wrote:

            
Thanks for making the data available for reproduction, makes debugging 
much easier! The same happens in GRASS:

Counting polygons for 19122 features...
Importing map 19122 features...
  100%
-----------------------------------------------------
Building topology for vector map <test_tmp>...
Registering primitives...
v.in.ogr: index.c:159: RTreeInsertRect1: Assertion `r->boundary[i] <= 
r->boundary[3 + i]' failed.

So the shapefile is broken, and the problem is in the software used by 
your collaborator. The specific problem is that all of the x-coordinates 
in entity 15755, first ring are NaN, not finite.

If you are able to install sp and rgdal from R-forge from source checked 
out from SVN, you can get the corrected error message:
OGR data source with driver: ESRI Shapefile
Source: ".", layer: "JustForest_BahiaSul_1990"
with 19122 features and 6 fields
Feature type: wkbPolygon with 2 dimensions
Error in stopifnot(is.list(srl)) : non-finite x coordinate

and now by setting useC=FALSE, retrieve the entity number for errors. 
readOGR() will actually correct non-closed rings automatically, so the 
error message as it stood was misleading.

So your collaborator has to create a new file with finite coordinates.

Hope this clarifies,

Roger