Tag Info

New answers tagged

1

Did you read http://postgis.net/docs/ST_Contains.html? ST_Contains — Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A. Creating SQL queries which construct geometry from WKT is a good and controlled way for testing the syntax select ST_Contains( ...


1

subprocess.call and subprocess.check_call both take lists with strings as input and separate each argument with a blank space. Your command would be: import os, subprocess base_path = "some/file/path" loadfile = os.path.join(base_path, "file.xml") command = ["C:\\Program Files\\QGIS Chugiak\\bin\\ogr2ogr.exe", "--config", "PG_LIST_ALL_TABLES", ...


2

You could make a tiny Python script, e.g. wkt2json.py #!/usr/bin/env python import sys from osgeo import ogr ogr.UseExceptions() print(ogr.CreateGeometryFromWkt(sys.argv[1]).ExportToJson()) And use it with the WKT in double quotes as the first and only argument: $ python wkt2json.py "POINT(4 5)" { "type": "Point", "coordinates": [ 4.0, 5.0 ] }


4

Use the SQLite in-memory database: :memory: ogr2ogr -f CSV /vsistdout/ ":memory:" -dialect sqlite \ -sql "SELECT AsGeoJSON(GeomFromText('POLYGON ((-94.1748 26.90248,-94.1748 27.60567,-93.07617 27.60567,-93.07617 26.90248,-94.1748 26.90248))', 4326)) AS wktIntersection"


2

Without knowing your dataset I can't be 100% sure, but I'd wager you can solve this by adding -dialect sqlite since ST_Intersects is a Spatialite SQL function. Your command should be /opt/gdal-custom/bin/ogr2ogr -f CSV /vsistdout/ foo.shp -dialect sqlite -sql "SELECT * FROM foo "


1

I guess that ST_Intersects(Geom1, Geom2) will test a spatial relationship between two elements and return a boolean (True or False), what you need here is probably ST_Intersection(Geom1, Geom2) if you want to create a geometry (resulting of the intersections of the two others passed in arguments). (If it is ST_Intersects() that you need, it should probably ...



Top 50 recent answers are included