it looks to me as if the implementation would be trivial
(code not yet tested just of the top of my head something
like this should work).
add to the class _Shape :
@property
def __geo_interface__(self):
if self.shapeType in [POINT, POINTM, POINTZ]:
return {
'type': 'Point',
'coordinates': tuple(self.points)
}
elif self.shapeType in [MULTIPOINT, MULTIPOINTM, MULTIPOINTZ):
return {
'type': 'MultiPoint',
#'coordinates': tuple(self.points)
}
elif self.shapeType in [POLYLINE, POLYLINEM, POLYLINEZ]:
return {
'type': 'LineString',
#'coordinates': tuple(self.points)
}
elif self.shapeType in [POLYGON, POLYGONM, POLYGONZ]:
return {
'type': 'Polygon',
#'coordinates': tuple(self.points)
}
I am not acquainted with the shapefile format enough to actually implement this
right now, but if you think this is a valuable addition to pyshp I
fork it and give it
a shot.
Q: does POLYLINE represent a LineString or a MultiLineString?
--
Best Regards,
Christian Ledermann
Nairobi - Kenya
Mobile :
+254 702978914
<*)))>{
If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.
1) Don’t drive species to extinction
2) Don’t destroy a habitat that species rely on.
3) Don’t change the climate in ways that will result in the above.
}<(((*>