Closed latot closed 4 weeks ago
It seems to "work" on Windows (no crash, but there is a message with error):
terra::as.polygons(terra::vect(sds::CGAZ(), query = sds::CGAZ_sql("Chile")))
class : SpatVector
geometry : polygons
dimensions : 135, 1 (geometries, attributes)
extent : -109.4555, -66.42422, -55.91544, -17.49834 (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84 (EPSG:4326)
Error in (function (cond) :
error in evaluating the argument 'x' in selecting a method for function 'as.data.frame': basic_string::_M_create
fwiw the output of CGAZ() and CGAZ_sql("Chile" ) is just
dsn <- "/vsizip//vsicurl/https://github.com/wmgeolab/geoBoundaries/raw/main/releaseData/CGAZ/geoBoundariesCGAZ_ADM0.zip"
qu <- "SELECT shapeGroup FROM geoBoundariesCGAZ_ADM0 WHERE shapeGroup IN ('CHL')"
vect(dsn, query = qu)
just as a workaround for @latot you don't need as.polygons, this is a shapefile in a zip read with a query
I think @latot used as.polygons()
because he was trying to convert from MULTIPOLYGON to POLYGON.
Hi, I was trying originally get the polygons as sf from the raster, and in the middle I found this issue.
https://gis.stackexchange.com/questions/452160/fast-way-to-convert-raster-to-polygon-shapefile-in-r
At least to me, without as.polygons()
it does not crash.
@mdsumner I'm looking to work with each raster cell as a sf polygon.
Fixed with https://github.com/rspatial/terra/commit/a0c09d9d35e120d5bffeb9fbf4cb2ce16eb3c65c
Your example is not with raster data. Treating a raster as polygons is almost never necessary, and almost always very inefficient
to convert from MULTIPOLYGON to POLYGON you can use disagg
Hi, here something weird:
Using this package for raster source: http://github.com/hypertidy/sds
There is more weird things, I checked this on stackoverflow: