1

I want calculate the intersected area between a shapefile and WKT geometry.

  • My target big layer: a.shp
  • My query small layer: 'POLYGON((1150046 1264030, 1160100 1263793, 1160079 1260606, 1150218 1260822, 1150046 1264030))'

I have the following ogrinfo expression that is actually working:

ogrinfo a.shp -dialect sqlite  -sql "SELECT id, sum(ST_Area(ST_Intersection(
GEOMETRY, ST_GeomFromText('POLYGON((1150046 1264030, 1160100 1263793, 1160079 1260606, 1150218 1260822, 1150046 1264030))')))) as m2 FROM a WHERE ST_Intersects(GEOMETRY, ST_GeomFromText('POLYGON((1150046 1264030, 1160100 1263793, 1160079 1260606, 1150218 1260822, 1150046 1264030))'))"

The SQL query is:

SELECT col1, sum(ST_Area(ST_Intersection(
GEOMETRY, ST_GeomFromText('POLYGON(( ... ))')))) as col2 
FROM a 
WHERE ST_Intersects(GEOMETRY, ST_GeomFromText('POLYGON(( ... ))'))"

Could this SQL query be written better to get faster results?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.