Solved

Adding Geolocation using pythonSDK


Badge +4

Hi Team, I need to add feature of geolocation to asset using python SDK can you help me with getting the geometry format if i have latitude and longitude information available with me . 

I have added the geolocation the asset but the same is not reflected to cdf ui .

icon

Best answer by Anita Hæhre 13 April 2023, 13:48

View original

4 replies

Hi, you can reference this code to create an asset with geo_location

from cognite.client import CogniteClient
from cognite.client.data_classes import GeoLocation, Geometry
c = CogniteClient()
geometry = Geometry(type="LineString", coordinates=[[30, 10], [10, 30], [40, 40]])
asset = Asset(name="my_pump", geo_location=
GeoLocation(type="Feature", geometry=geometry)
)

you can take a look at different supported Geometry object at https://github.com/cognitedata/cognite-sdk-python/blob/c95086e952d9e63aa72e7c68911d32e92ecfbbca/cognite/client/data_classes/shared.py#L53

PS: I haven’t tested the code yet. But it should provide you an idea how to work with geo_location of Asset

Badge +4

Hi @tuan.nguyen , thanks for the reply , i have already tried the same , the issue now is when i retrieve the asset using sdk i can see geolocation updated but when i go to see in CDF UI , i cannot see the same .

Hi @vidhi.c.jain , which CDF application/UI are you using?

Userlevel 6
Badge

Hi @vidhi.c.jain I hope the above resolved. I’ll be closing this ticket for now as we’ve not heard back from you in a while. Feel free to open it again should you have any related questions. 

Reply