I'm reading in polygons from ArcMap 10.6.1 into R 3.5.1 using raster::shapefile
. I sometimes get the following warning:
Warning message: In rgdal::readOGR(dirname(x), fn, stringsAsFactors = stringsAsFactors, : Z-dimension discarded
I'm confused because I'm not even employing rgdal to read in. Area calculations using the resulting SpatialPolygonsDataFrame are incorrect, and I think this error reading in is why. It's projection is
CRS arguments: +proj=utm +zone=12 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
I've tried readOGR and get the same warning. I am able to read in some other shape files in the same way with the same projection, and they work just fine. Why do I get this warning and how can I remedy it?
Edit: reading in using sp::st_read does not return an issue re: Z-dimensions until I try to convert. However, I need a SpatialPolygonsDataFrame to do what I need to do but this is how the file reads in:
Simple feature collection with 1 feature and 5 fields
geometry type: MULTIPOLYGON
dimension: XYZ
bbox: xmin: 365305.5 ymin:5809943 xmax: 476043.9 ymax: 5891941
epsg (SRID): 32612
proj4string: +proj=utm +zone=12 +datum=WGS84 +units=m +no_defs
How do I convert to a spdf? df::as_Spatial return this error:
Error in StopZ(zm) : sp supports Z dimension only for POINT and MULTIPOINT. use
drop_zm(...)
to coerce to XY dimensions