Error importing ESRI Shapefile
On Tue, 10 Mar 2015, Alec Friedhoff wrote:
Hi Frede,
My apologies for the incomplete question. I did post on stackoverflow and stackexchange, but have deleted the latter post (I've never visited onlinedevs.com). For what it's worth, I do update questions I've asked on sites like stackoverflow if I find answers elsewhere, but I do understand your general annoyance.
Here's some more information:
Output of traceback():
4: .Call("make_Polygonlist", iG, gComments[[i]], PACKAGE = "rgdal")
3: stopifnot(is.list(srl))
2: Polygons(.Call("make_Polygonlist", iG, gComments[[i]], PACKAGE = "rgdal"),
ID = as.character(fids[i]))
1: readOGR("/geo/layers", "tracts")
This detail helps, but does not provide a reproducible example. The error message said: "infinite label point" which comes from a validity check on a Polygon or possibly Polygons object. The C code in the sp package, called from rgdal, computes the centroid, but appears here to fail because the area of the polygon is not close to zero. Close to zero cases (a repeated point trying to pretend to be a polygon, or a short line doing the same) are covered. This means that your polygon is the first ever encountered in this unusual state. Either make the offending shapefile available on a public server and post the link, or contact me off-list with that link, or with a zip archive of the shapefile attached, again off-list. I'll try to see whether additional logic can be added to identify the bad geometries. Roger
Message I receive upon loading of rgdal library:
Loading required package: sp
rgdal: version: 0.9-1, (SVN revision 518)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.10.1, released 2013/08/26
Path to GDAL shared files: /usr/share/gdal/1.10
Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
Path to PROJ.4 shared files: (autodetected)
ogrDrivers() reveals I do have Shapefile support:
name write
1 AeronavFAA FALSE
2 ARCGEN FALSE
3 AVCBin FALSE
4 AVCE00 FALSE
5 BNA TRUE
6 CouchDB TRUE
7 CSV TRUE
8 DGN TRUE
9 DODS FALSE
10 DXF TRUE
11 EDIGEO FALSE
12 ElasticSearch TRUE
13 ESRI Shapefile TRUE
14 Geoconcept TRUE
...
Output of sessionInfo():
R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_0.9-1 sp_1.0-17
loaded via a namespace (and not attached):
[1] grid_3.1.2 lattice_0.20-30 tools_3.1.2
Output of ogrListLayers():
[1] "tracts"
attr(,"driver")
[1] "ESRI Shapefile"
attr(,"nlayers")
[1] 1
Output of ogrInfo():
Source: "/geo/layers", layer: "tracts"
Driver: ESRI Shapefile number of rows 73682
Feature type: wkbPolygon with 2 dimensions
Extent: (-179.1473 17.88124) - (179.7785 71.39048)
CRS: +proj=longlat +datum=WGS84 +no_defs
LDID: 0
Number of fields: 34
name type length typeName
1 FIPS 4 11 String
2 SQMI 2 16 Real
...
Any help is greatly appreciated.
Best,
Alec
From: frtog at vestas.com To: hrbuilder at hotmail.com; r-sig-geo at r-project.org Date: Tue, 10 Mar 2015 09:49:55 +0100 Subject: RE: [R-sig-Geo] Error importing ESRI Shapefile Hi Alec It is very impolite to cross post you questions. Besides the r-sig-geo you have probably posted on 1) http://onlinedevs.com/problem-reading-shapefile-using-r/ 2) http://gis.stackexchange.com/questions/138217/problem-reading-shapefile-using-r 3) http://stackoverflow.com/questions/28957014/error-reading-in-esri-shapefile-using-r Are those sites sharing information? Do people on those sites see my specific answer to your question on r-sig-geo? Also please do not post in html but in plain text. Set your email client to post in text when posting to r-sig-geo. Nobody can really help you. You give no information from which we can see why you get this error message. To make you help us to help you please do something along this route. If you get an error please issue an
traceback()
at command prompt in the R shell. Now do this at R prompt:
library(rgdal)
and post the output from that call probably something like this: " Loading required package: sp rgdal: version: 0.9-1, (SVN revision 518) Geospatial Data Abstraction Library extensions to R successfully loaded Loaded GDAL runtime: GDAL 1.11.1, released 2014/09/24 Path to GDAL shared files: c:/Programmer/R/R-3.1.2/library/rgdal/gdal GDAL does not use iconv for recoding strings. Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480] Path to PROJ.4 shared files: c:/Programmer/R/R-3.1.2/library/rgdal/proj"
sessionInfo()
Post the output!
ogrDrivers()
dsn <- "/path/to/layer"
file.choose(dsn)
Can you see any shapefiles?
ogrListLayers(dsn)
Can you see any layer names?
ogrInfo(dsn=dsn, layer="layer")
Any information from this call? Yours sincerely / Med venlig hilsen Frede Aakmann T???gersen Specialist, M.Sc., Ph.D. Plant Performance & Modeling Technology & Service Solutions T +45 9730 5135 M +45 2547 6050 frtog at vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender.
-----Original Message-----
From: R-sig-Geo [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of Alec
Friedhoff
Sent: 10. marts 2015 07:21
To: r-sig-geo at r-project.org
Subject: [R-sig-Geo] Error importing ESRI Shapefile
Hi all,
I'm trying to read in a Shapefile using the rgdal library, and am unable to do
so.When using the following code, geo <-
readOGR("/path/to/layer","layer"),I'm met with the error "Error in
stopifnot(is.list(srl)) : infinite label point"
This one has me stumped. My searches haven't yielded any useful
information about this error. I suspect there are some bad geometries in the
underlying file. I have access to ArcMap and tried running the
RepairGeometry_management method of arcpy, but this has no effect.
How can I go about understanding this error and ultimately fixing it?
Many thanks!
-HR
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[[alternative HTML version deleted]]
Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 91 00 e-mail: Roger.Bivand at nhh.no