<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>Example from my own application, you should be able to modify that to fit your case.</div><div><br></div><div>SELECT row_to_json(f) As feature FROM (SELECT 'Feature' As type, ST_AsGeoJSON(ST_Transform(l.geometry, 4326))::json As geometry, row_to_json((SELECT l FROM (SELECT id, 'l' AS type, name, area) As l)) As properties FROM lakes As l where l.id = 123456 ) As f;</div><div><br></div><div>-ra</div><br><div><div>On 28 Aug 2014, at 16:55, Max Demars <<a href="mailto:burton449geo@gmail.com">burton449geo@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Hi list,<br><br><table><tbody><tr><td class=""><br></td>
<td class=""><br></td></tr></tbody></table>I would like to get a geojson feature with properties from PostGIS. I have found <a href="http://www.postgresonline.com/journal/archives/267-Creating-GeoJSON-Feature-Collections-with-JSON-and-PostGIS-functions.html">an example</a> to have a feature collection but I can't make it works for just a feature.<br>
<br>so far I modified the feature collection query but the output is not valid:<br><br> "SELECT row_to_json(fc) \<br> FROM (SELECT 'Feature' As type \<br> , ST_AsGeoJSON(%s)::json As geometry \<br>
, row_to_json((id_relat,id)) As properties \<br> FROM shapefile_feature WHERE id=%s)As fc;" % (geometryField, <a href="http://feature.pk/">feature.pk</a>)<br>
<br>invalid output:<br><br> {<br> u'geometry':{<br> u'type':u'MultiPolygon',<br> u'coordinates':[<br> [<br> [<br> [<br>
-309443.24253826,<br> 388111.579584133<br> ],<br> [<br> -239422.232645415,<br> 395845.012821243<br> ],<br>
[<br> -136320.430677211,<br> 389768.695489968<br> ]<br> ]<br> ]<br> ]<br> },<br> u'type':u'Feature',<br>
u'properties':{<br> u'f1':0,<br> u'f2':489445<br> }<br> }<br><br></div>Anyone can help here?<br clear="all"><div><br>-- <br><div dir="ltr"><div><div>Stack Overflow: <a href="http://stackoverflow.com/users/1914034/burton449" target="_blank">http://stackoverflow.com/users/1914034/burton449</a><br>
</div>GIS Overflow: <a href="http://gis.stackexchange.com/users/14426/burton449" target="_blank">http://gis.stackexchange.com/users/14426/burton449</a><br></div>LastFm: <a href="http://www.lastfm.fr/user/burton449" target="_blank">http://www.lastfm.fr/user/burton449</a><br>
</div>
</div></div>
_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</blockquote></div><br></body></html>