Skip to main content
Practitioner ⭐️
Apr 28, 2023 9:01 AM UTC
Solved

Filtering assets by geolocation using pythonSDK [Community Contributedl]

How can I filter assets by their geolocation using the python SDK?

from cognite.client.data_classes import GeoLocationFilter, GeometryFilter

mygeofilter = GeoLocationFilter(
relation="within",
shape=GeometryFilter(
type="Polygon",
coordinates=[[[7, 61], [13, 61], [10, 55], [7, 61]]]
)
)

client.assets.list(geo_location=mygeofilter)

This approach works for files, but for assets I get:

CogniteAPIError: Unexpected value 'within' | code: 400 | X-Request-ID: fd1c5a73-a3d3-9ec1-bd97-039b4b1e0051
Architect
Apr 28, 2023 12:07 PM UTC

Hi Kristian, thanks for asking! Seems that the relation parameter is case sensitive, can you please try relation=“WITHIN”? 

Supported keywords are INTERSECTS, DISJOINT and WITHIN. 

2 replies

Architect
Apr 28, 2023 12:07 PM UTC

Hi Kristian, thanks for asking! Seems that the relation parameter is case sensitive, can you please try relation=“WITHIN”? 

Supported keywords are INTERSECTS, DISJOINT and WITHIN. 

Dilini Fernando
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
Jul 7, 2023 2:04 PM UTC

Hi @Kristian Nymoen,

We appreciate your contribution to our community! We’ve chosen to move your article to our hub's How-To section as it will greatly benefit other members of our community. Thank you for your understanding, and we look forward to seeing more great contributions from you in the future! 

Best regards,
Dilini