Skip to content

Geometry filter that worked in 2.6 does not work in 2.7 #1038

@s6hebern

Description

@s6hebern

Expected behavior
In version 2.6, the attached search filter worked fine. Attaching the original geojson as well (had to rename it to "json" to be able to upload).
bunthaus.json
planet_search_filter.json

Actual behavior (describe the problem)
In version 2.7, that same search filter returns the following error:
planet_error.txt

Minimum, Complete, Viable Code Sample
Tried my best to extract the relevant functions from a much larger script.

import datetime
import asyncio
import geopandas as gpd
from planet import Auth, data_filter, Session


def prepare_aoi(aoi):
    gdf = gpd.read_file(aoi)
    # make MultiPolygon
    if gdf.geometry.count() > 1:
        log.warn('Found multiple features! Morphing them into one multipart feature ...')
        multipart = gpd.tools.collect(gdf.geometry)
        crs = gdf.crs
        gdf = gpd.GeoDataFrame({'id': [0], 'geometry': [multipart]}, crs=crs)
        gdf.to_crs(epsg=4326, inplace=True)
    return json.loads(gdf.to_json())


async def search_scenes(geojson, start, end, api_key):
    search_filter = data_filter.and_filter([
        data_filter.permission_filter(),
        data_filter.string_in_filter('instrument', ['PSB.SD', ]),
        data_filter.date_range_filter('acquired', gte=start),
        data_filter.date_range_filter('acquired', lte=end),
        data_filter.geometry_filter(geojson),
    ])
    async with Session(auth=Auth.from_key(api_key)) as session:
        client = session.client('data')
        return {item.get('id'): item.get('properties').get('cloud_cover') * 100 async for item in
                client.search(['PSScene'], search_filter, limit=0)}


if __name__ == '__main__':
    # "MY_GEOJSON" needs to be the real file
    geojson = prepare_aoi(MY_GEOJSON)
    start = datetime.datetime(2023, 9, 25)
    end = datetime.datetime(2023, 9, 30)
    # provide working API key here
    await search_scenes(geojson, start, end, API_KEY)

Workaround
Downgrade to version 2.6

Environment Information

  • Operation System Information: Windows 11
  • Python version: 3.10
  • Planet package version (planet -v): 2.7

Installation Method
pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions