2

Let's say I have a geopandas.GeoDataFrame with a shapely.geometry.polygon.Polygon as geometry type.

The problem is that I have an attribute per vertex of the polygon, which could theoretically be stored in the shapefile's M slot. The only problem is that I could not find an option to include this M into the polygon. The shapely documentation says:

The Polygon constructor takes two positional parameters. The first is an ordered sequence of (x, y[, z]) point tuples [...]

Further, when using the geopandas.GeoDataFrame.to_file method, I couldn't find an option to insert this kind of information.

Can anyone help?

3
  • If Z is not reserved use that instead of M. – user30184 Jan 21 '18 at 15:46
  • Good point! Unfortuntately, Z is indeed used in some of the polygons I have... – countryman Jan 21 '18 at 15:48
  • 1
    I fear that you must put the vertices into a new point layer with vertex index as one attribute and save the measures into another attribute. – user30184 Jan 21 '18 at 15:52
3

Shapely only considers Cartesian coordinates. M – which exists in the shapefile format so we can record accurate distance between points on otherwise roughly digitized lines (mile markers, etc) – is outside of Shapely's scope.

1
  • Thanks @sgillies! Probably the correct answer to the question! – countryman Jan 25 '18 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.