I have seen that OGR supports it's own form of SQL, I was wondering if it's possible to do spatial joins.
Something like select all objects where one intersects the other. I did have a look around but couldn't really see anything.
Answer
The OGR SQL is only for standard attribute queries, and not for spatial queries.
http://www.gdal.org/ogr/ogr_sql.html
The only geometry related queries that can be run are to query by area using the keyword OGR_GEOM_AREA
SELECT * FROM nation WHERE OGR_GEOM_AREA > 10000000'
If you run the OGR SQL against a datasource that is a database then the SQL query is executed using the database's own SQL implementation.
You can also pass in spatial queries directly to a geodatabase using the ExecuteSQL command on a OGRDataSource. This method also allows a bonding box to be passed in as a filter.
To do queries such as intersections with OGR you'd need to use the OGRGeometryClass. Personally I find it easier to use the opensource Shapely library for these types of query, or use the spatial queries in the underlying geodatabase (SQL Server, Oracle, PostGIS etc.)
No comments:
Post a Comment