Skip to main content
Answer

Filtering assets by geolocation using pythonSDK [Community Contributedl]

  • April 28, 2023
  • 2 replies
  • 86 views

Forum|alt.badge.img+4

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

Best answer by palronning

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
  • Answer
  • April 28, 2023

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
Seasoned Practitioner
Forum|alt.badge.img+2

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