data_filter.range_filter should allow for "area_coverage"
sterlingbaldwin opened this issue · 2 comments
Is your feature request related to a problem? Please describe.
When trying to find images that cover a specific area, currently all images that have any intersection with the geometry are returned. That means if one tiny section of a corner intersects your AOI the image will be returned as part of the search.
Describe the solution you'd like
The Explorer web app solves this problem by allowing users to search with an "area coverage" slider, allowing users to only get images that have some minimum area intersection with their AOI.
Describe alternatives you've considered
Writing it myself in python, but this is a pain and its already a feature in the Explorer app. Since its not in the API and is in the web app, I think this could be added to the SDK without any need to change the API itself.
Additional context
Tiny little code snippet that might be handy, this doesnt do the whole feature request but it does do what I really wanted which was to find images that had the maximum coverage intersection. The dicts
parameter being the results from a normal image search, and the aoi being a geojson object.
from shapely.geometry import Polygon
def find_max_overlap(dicts, aoi):
max_overlap = 0
max_dict = None
polygon = Polygon(aoi['coordinates'][0])
for data_dict in dicts:
coordinates = data_dict['geometry']['coordinates']
data_polygon = Polygon(coordinates[0])
overlap = data_polygon.intersection(polygon).area
if overlap > max_overlap:
max_overlap = overlap
max_dict = data_dict
print(f"Max image overlap {(max_overlap/polygon.area)*100}%")
return max_dict['id']
@sterlingbaldwin the SDK is intended to be fairly low level and only provide easy Python access to the Planet APIs. Python tools that orchestrate API calls are going to go here: https://github.com/planetlabs/planet-tools-python.
You'll recognize this code right away, I think! https://github.com/planetlabs/planet-tools-python/blob/main/src/planet_tools/coverage.py#L188-L193 😄