Advertisement
Guest User

Untitled

a guest
Aug 30th, 2017
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. $ogr2ogr -f GeoJSON out.json "PG:host=localhost dbname=xxx user=xxx password=xxx"
  2. -sql 'select id, county, wkb_geometry from cities where id=47927526'
  3.  
  4. SELECT row_to_json(featcoll)
  5. FROM
  6. (SELECT 'FeatureCollection' As type, array_to_json(array_agg(feat)) As features
  7. FROM (SELECT 'Feature' As type,
  8. ST_AsGeoJSON(tbl.geom)::json As geometry,
  9. row_to_json((SELECT l FROM (SELECT id, prop1, prop2, ...) As l)
  10. ) As properties
  11. FROM your_table As tbL
  12. WHERE st_intersects(geom, st_setsrid(st_makebox2d(st_makepoint(x1, y1),st_makepoint(x2, y2)), srid))
  13. ) As feat
  14. ) As featcoll;
  15.  
  16. $ogr2ogr -f GeoJSON out.json "PG:host=localhost dbname=xxx user=xxx password=xxx"
  17. -sql 'select id, county, wkb_geometry from cities where id=47927526'
  18.  
  19. $ogr2ogr -f GeoJSON out.json "PG:host=localhost dbname=xxx user=xxx password=xxx"
  20. -sql 'select id, county, wkb_geometry from cities where id IN (47927526, 47927527, 47927528, 47927529, ...)'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement