[postgis-users] Get a feature geojson from postgis
Max Demars
burton449geo at gmail.com
Thu Aug 28 07:55:08 PDT 2014
Hi list,
I would like to get a geojson feature with properties from PostGIS. I have
found an example
<http://www.postgresonline.com/journal/archives/267-Creating-GeoJSON-Feature-Collections-with-JSON-and-PostGIS-functions.html>
to have a feature collection but I can't make it works for just a feature.
so far I modified the feature collection query but the output is not valid:
"SELECT row_to_json(fc) \
FROM (SELECT 'Feature' As type \
, ST_AsGeoJSON(%s)::json As geometry \
, row_to_json((id_relat,id)) As properties
\
FROM shapefile_feature WHERE id=%s)As fc;"
% (geometryField, feature.pk)
invalid output:
{
u'geometry':{
u'type':u'MultiPolygon',
u'coordinates':[
[
[
[
-309443.24253826,
388111.579584133
],
[
-239422.232645415,
395845.012821243
],
[
-136320.430677211,
389768.695489968
]
]
]
]
},
u'type':u'Feature',
u'properties':{
u'f1':0,
u'f2':489445
}
}
Anyone can help here?
--
Stack Overflow: http://stackoverflow.com/users/1914034/burton449
GIS Overflow: http://gis.stackexchange.com/users/14426/burton449
LastFm: http://www.lastfm.fr/user/burton449
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20140828/48cfde5b/attachment.html>
More information about the postgis-users
mailing list