[Geojson] regexp for converting WKT to GeoJSON geometry

Sean Gillies sgillies at frii.com
Mon Aug 25 08:39:19 PDT 2008


Kralidis,Tom [Burlington] wrote:
> Hi: anyone have such a thing around in perl, php, or python?
> 
> Thanks
> 
> ..Tom

Alternatively, you could use the Shapely and Geojson packages for Python:

>>> from shapely.wkt import loads
>>> x = loads('POINT (0.0 0.0)')
>>> from geojson import dumps
>>> dumps(x)
'{"type": "Point", "coordinates": [0.0, 0.0]}'

It's all based on tested, production-ready code. Shapely uses the GEOS
WKT parser. Geojson extends the simplejson module.

Sean



More information about the GeoJSON mailing list