Geographic Information Systems Asked by its30 on February 2, 2021
I am using the world borders dataset to try and perform an intersection based on the buffer of a point. I need to return the country with the largest area within the buffer.
For example, in the diagram below my query should return the United States:
This query is incorrectly returning Canada:
point = WKTElement('POINT({} {})'.format(*center_point), srid=4326)
q = db.session.query(WorldBorders.iso2, WorldBorders.geom)
.filter(func.ST_Intersects(WorldBorders.geom, func.ST_Buffer(point, 1))).first()
Do I need to use an aggregate function and group_by?
This is getting me the expected results:
point = WKTElement('POINT({} {})'.format(*center_point), srid=4326)
q = db.session.query(WorldBorders.iso2, WorldBorders.geom)
.order_by(func.ST_Area(func.ST_Intersection(func.ST_Buffer(point, 1),
WorldBorders.geom)).desc()).first()
Answered by its30 on February 2, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP