Closed mdsumner closed 8 years ago
Thanks for the link -- seems to work well:
> library(sf)
Linking to GEOS 3.5.0, GDAL 2.1.0
> s = st_read(".", "w001n05f")
Reading layer w001n05f from data source . using driver "ESRI Shapefile"
features: 16
fields: 1
geometry type: POLYGON
> plot(s)
> st_geometry(s)
Simple feature collection with 16 features
feature type: POLYGON
dimension: XYZ
bbox: xmin: -1.000139 ymin: 4.999861 xmax: 0.0001388889 ymax: 5.992361
epsg (SRID): NA
proj4string: NA
precision: double (default; no precision model)
First 5 geometries:
POLYGONZ((-0.795416666666667 5.99208333333333 1...
POLYGONZ((-0.0359722222222221 5.73763888888889 ...
POLYGONZ((-0.0706944444444444 5.72402777777778 ...
POLYGONZ((-0.102916666666667 5.68652777777778 1...
POLYGONZ((-0.0373611111111111 5.63013888888889 ...
I'm finding if one reads in a file that has an empty Z dimension, this error is produced
Error in .local(obj, ...) : NA values in coordinates
and so far, I haven't found a native (sf) way to drop the Z dimension...
I should clarify, I only receive that error when trying to coerce back to sp classes using
as(test_sf, "Spatial")
I also tried this...
test_asSPDF <- as(na.omit(test_sf), "Spatial")
Error in .local(obj, ...) : NA values in coordinates
And, for what it's worth:
all(sf::st_is_valid(test_sf))
returns TRUE
all(sf::st_is_simple(test_sf))
returns TRUE
try st_dropzm
, now added.
Thanks @edzer, will give it a try!
These look like a good set for testing on:
http://dds.cr.usgs.gov/srtm/version2_1/SWBD/SWBDwest/
found on the Worldwind forum: http://forum.worldwindcentral.com/showthread.php?26821-Sample-3-D-Shapefile