I'm undertaking a fairly simple workflow all within a python script with the goal of passing urlencoded GeoJSON in a URL to the Mapbox static API:
- create a point from DD string in
- convert to UTM for easier units and buffer the point generating a polygon
- transform back to WGS84 for the API
- generate valid, URL encoded GeoJSON string.
My hangup is the last part. I've used Shapely and pyproj to conduct 1-3 but using:
json.dumps(mapping(<shapely.geometry.polygon.Polygon at 0x106a22690>)) (and several permutations of this) and encoding it using
url_quote generates an encoded URL with JSON that returns 'Invalid Geojson' from Mapbox.
I am optimistic that the
geojson library may solve this, but I can't seem to find a simple way to convert a shapely Polygon object to a GeoJSON polygon object.