You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into some data from here. (400mb zipped gdb) that has one geometry that comes back as a "MULTICURVE/COMPOUNDCURVE".
This was causing st_simplify to fail with the error: ParseException: Unknown WKB type 11 and I can't plot the geometry.
I'm wondering if it would be a terrible idea to attempt piece-wise coercion to LINESTRING to create a MULTILINESTRING out of a MULTICURVE?
Happy to hear, no that's a terrible idea because of side affects or whatever. We can just close this for a future me to find when googling error messages. But there's a potential fix for the issue shown below and I'll submit for consideration -- I'm not familiar enough with the vagaries of sf geometries to feel comfortable submitting a PR for this though.
Here's a reprex showing what I'm talking about and my hack to "fix" it.
library(sf)
#> Linking to GEOS 3.7.2, GDAL 2.4.1, PROJ 5.2.0# WKT truncated for reprexwkt<-"MULTICURVE (COMPOUNDCURVE (LINESTRING (-83.62333 35.55244, -83.62328 35.55232, -83.62323 35.55223, -83.62319 35.55216, -83.62312 35.55209, -83.6231 35.55207), CIRCULARSTRING (-83.6231 35.55207, -83.62307 35.55205, -83.62302 35.55204), LINESTRING (-83.62302 35.55204, -83.62299 35.55203, -83.62289 35.55198, -83.62281 35.55189, -83.62271 35.55182)))"g<- st_as_sfc(wkt)
g<- st_sf(demo="test", geom=g, crs=4326)
try(plot(st_geometry(g)), silent=FALSE)
#> Error in xy.coords(x, y, xlabel, ylabel, log) : #> 'x' is a list, but does not have components 'x' and 'y'
try(st_simplify(st_transform(g, 5070), dTolerance=10), silent=FALSE)
#> Error in CPL_geos_op("simplify", x, numeric(0), integer(0), preserveTopology = rep(preserveTopology, : #> Evaluation error: ParseException: Unknown WKB type 11.fix<- which(sapply(st_geometry(g), function(x) class(x)[2]) !="MULTILINESTRING")
for(finfix) {
st_geometry(g)[[f]] <- st_multilinestring(lapply(st_geometry(g)[[f]][[1]], st_cast, to="LINESTRING"), dim="XY")
}
if(length(fix) >0) st_geometry(g) <- st_sfc(st_geometry(g)[[1]], crs= st_crs(g))
plot(st_geometry(g))
I believe that you can use the utility ogr2ogr through gdal_utils() in sf to turn curves into line strings manually before reading, not ideal, but worked - cannot now find the relevant issue (I might have raised it by email too).
I ran into some data from here. (400mb zipped gdb) that has one geometry that comes back as a "MULTICURVE/COMPOUNDCURVE".
This was causing
st_simplify
to fail with the error:ParseException: Unknown WKB type 11
and I can't plot the geometry.I'm wondering if it would be a terrible idea to attempt piece-wise coercion to LINESTRING to create a MULTILINESTRING out of a MULTICURVE?
Happy to hear, no that's a terrible idea because of side affects or whatever. We can just close this for a future me to find when googling error messages. But there's a potential fix for the issue shown below and I'll submit for consideration -- I'm not familiar enough with the vagaries of sf geometries to feel comfortable submitting a PR for this though.
Here's a reprex showing what I'm talking about and my hack to "fix" it.
Created on 2019-11-18 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: