Closed mdsumner closed 2 years ago
The problem here is that the validation checks return the bad geometries in a sfc_GEOMETRY, and plot.sfc_GEOMETRY doesn't have capability to ignore empties (I think).
Example 1
[1] "land_use_2013_BRS"
Error in CPL_geos_is_empty(st_geometry(x)) :
Evaluation error: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4.
In addition: Warning messages:
1: In title(...) : "border" is not a graphical parameter
2: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet, :
GDAL Message 1: organizePolygons() received an unexpected geometry. Either a polygon with interior rings, or a polygon with less than 4 points, or a non-Polygon geometry. Return arguments as a collection.
3: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet, :
GDAL Message 1: organizePolygons() received an unexpected geometry. Either a polygon with interior rings, or a polygon with less than 4 points, or a non-Polygon geometry. Return arguments as a collection.
Example 2
[1] "land_use_2015_BRS_statewide"
Error in CPL_geos_is_empty(st_geometry(x)) :
Evaluation error: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4.
(Very likely) local logic to separate layers is not sufficient here, also for "land_use_2015_BRS"
[1] "tasveg_30"
Error in rbind.data.frame(...) :
numbers of columns of arguments do not match
Some patterns are finding no files. ??
Something like this will do it, after "border" handling and before "st_is_empty" in plot.sfc_MULTIPOLYGON:
bad = st_is_valid(x)
if (any(is.na(bad))) {
x = x[!is.na(bad)]
if (length(x) < 1) {
warning("no valid geometries to plot in sfc_MULTIPOLYGON")
return(invisible(NULL))
}
}
Need to test other functions, and compare for the other cases above where they are GEOMETRY type.
BUT, it is just the shitty shapefiles - use the MapInfo TAB and all is well.
use basf to solve the annoying sf plot
Script to read all statewide layers (binding municipalities as needed).
Script output