Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created April 19, 2013 21:55
Show Gist options
  • Save springmeyer/5423500 to your computer and use it in GitHub Desktop.
Save springmeyer/5423500 to your computer and use it in GitHub Desktop.
example of working with geojson, wkt, and wkb in mapnik python api
>>> import mapnik
>>> path = mapnik.Path.from_geojson('{ "type":"Point","coordinates":[-122,48] }')
>>> path.envelope()
Box2d(-122.0,48.0,-122.0,48.0)
>>> path.to_geojson()
'{"type":"Point","coordinates":[-122,48]}'
>>> path.to_wkt()
'Point(-122 48)'
>>> path.to_wkb(mapnik.wkbByteOrder.NDR)
'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x80^\xc0\x00\x00\x00\x00\x00\x00H@'
>>> path.to_wkb(mapnik.wkbByteOrder.XDR)
'\x00\x00\x00\x00\x01\xc0^\x80\x00\x00\x00\x00\x00@H\x00\x00\x00\x00\x00\x00'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment