Search code examples
gdalgeopandasshapefile

Reading M-Values from shapefiles using GeoPandas/Fiona


I am working with a set of line features (roads) that are represented as "polyline ZM" in shapefiles. However, when using geopandas/fiona to read the shapefiles, the return geometry is always LineString Z. I read online that GDAL supports reading M-values from shapefiles.

I am wondering if there is a way I can load the M-values from shapefiles in python. Because so far I haven't had any luck in my googling, maybe I am just not looking into the right places.

(P.S. I prefer not to use arcpy if possible) Thanks in advance!


Solution

  • Geopandas can't properly read geometries with M-values. This seems to be an upstream problem with the libraries that GeoPandas uses. See these github issue threads for more info:

    Sadly, it doesn't seem like it's getting fixed anytime soon.

    If you want, you can also use the Python GDAL/OGR libraries. It is SIGNIFICANTLY more cumbersome than using GeoPandas, but it does support geometries with M-values. See the following links for more explicit examples on how to use them: