The Z dimension of geometries is not preserved when using gpd.to_file() using the ESRI driver.
import geopandas as gpd
from shapely.geometry import Point
point = Point(0, 0, 500)
gdf = gpd.GeoDataFrame(geometry=[point])
print(gdf)
geometry
0 POINT Z (0 0 500)
md5-c8646c095092cb1a3ce47b0c1609ee3c
FID geometry
0 0 POINT (0 0)
```
I'd expect the Z dimension to be included.
@mattayes Thanks for the clear bug report! It looks like geopandas isn't correctly inferring a "3D Point" geometry schema. Are you interested in making a PR on this? If not, I can take a shot in the next week or two.
@jdmcbr I'm interested, though I'm not quite sure what needs to change right now. Do you have a good idea? I'm happy to start investigating.
To further investigate, could you open the written file with another program? Just to know whether the bug is in the writing of the file, or in the reading it afterwards? (or if you have an existing 3D shapefile, to try to read that)
@mattayes @jorisvandenbossche I'm sorry, I should have provided a little more detail in my previous message. In confirming this was a geopandas issue and not a fiona issue, I saw that this was occurring during a write. For a 3D point file written with fiona, geopandas correctly read it back in.
I suppose the error is in inferring the schema (https://github.com/geopandas/geopandas/blob/master/geopandas/io/file.py#L111), in that it needs special casing for 3D data.
If you manually specify the schema, it seems to work:
In [167]: point = Point(0, 0, 500)
...: gdf = gpd.GeoDataFrame({'a': [1]}, geometry=[point])
In [168]: gdf
a geometry
0 1 POINT Z (0 0 500)
In [170]: gpd.io.file.infer_schema(gdf)
Out[170]: {'geometry': 'Point', 'properties': OrderedDict([('a', 'int')])}
In [175]: schema = {'geometry': '3D Point', 'properties': {'a': 'int'}}
In [176]: gdf.to_file("__test3D.shp", schema=schema)
In [177]: gpd.read_file("__test3D.shp")
a geometry
0 1 POINT Z (0 0 500)
Although I don't fully understand how it works, as here (https://github.com/Toblerity/Fiona/issues/465) is stated that '3D Point' should now be an alias for 'Point'