Skip to content
Prev 5376 / 29559 Next

Issues importing BIG shapefile - Limitations of R or something else?

On Sun, 29 Mar 2009, Tyler Dean Rudolph wrote:

            
Tyler:

Thanks again for a full report. The failure in readShapeLines() was caused 
by a line with only a single coordinate (two, in fact). This isn't a 
problem in the readOGR() code, and will not be in the latest release of 
maptools.

In spatstat, if spatstat.options("checkpolygons") is TRUE, (xrange[2] < 
xrange[1]) and (yrange[2] < yrange[1]) are both expected to hold, and 
cannot, because for single coordinate lines, the min and max are equal.

You have two choices - based on the files you made available, either drop 
the two single coordinate lines:

ncrds <- sapply(slot(roads, "lines"), function(x) sapply(slot(x, "Lines"),
   function(y) nrow(slot(y, "coords"))))
summary(unlist(wh_singleton))
keep <- sapply(ncrds, function(x) all(x > 1))
roads_gt_1 <- roads[keep]
length(slot(roads, "lines"))
length(slot(roads_gt_1, "lines"))
test <- as(roads_gt_1, "psp")

or set checkpolygons to FALSE in spatstat.options(). I'm running the 
former at the moment - deleting the SpatialLinesDataFrame object after 
coercing to SpatialLines would save some memory.

Hope this helps,

Roger