Solved

Filtering assets by geolocation using pythonSDK [Community Contributedl]

  • 28 April 2023
  • 2 replies
  • 64 views

Userlevel 2
Badge +3

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
icon

Best answer by palronning 28 April 2023, 14:07

View original

2 replies

Userlevel 2

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. 

Userlevel 4
Badge +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 

 

Reply