Solved

Assets with GeoLocation and large polygons

  • 8 February 2024
  • 3 replies
  • 110 views

Userlevel 2
Badge +3

Hi.

We’re looking at how to work with larger geographic areas - inflow catchments for our hydropower reservoirs. The smallest one being a polygon with 3119 coordinates. Trying to create these catchments as assets with geolocation fails, due to the size limit on the GeoLocation field. Error message: “Maximum size of GeoLocation field is 10240.

I assume this means that the preferred approach is to use GeoSpatial, rather than assets with a geolocation field? 

  • If so, is the assetIds property the preferred way to connect GeoSpatial objects to assets? 
  • And is there a simple way to retrieve the shape of an asset using the Python SDK? (something equivalent to using asset.geolocation?)
  • Also; Any plans for showing geolocation ar geospatial information in the Fusion UI?

 

icon

Best answer by Vincent Gay 9 February 2024, 11:37

View original

3 replies

Hi Kristan,

The Geospatial API would indeed allow you to bypass the Assets API limit. Geospatial support large geometries (50Mb per request). However, the Geospatial is now with limited support and I am not sure it of its future at this point.

But to answer your questions:

> If so, is the assetIds property the preferred way to connect GeoSpatial objects to assets? 

yes, that’s what the property is made for

> is there a simple way to retrieve the shape of an asset using the Python SDK? (something equivalent to using asset.geolocation?)

yes, the python sdk can be installed with geopandas and other libs that enable manipulation and the geometries

> Any plans for showing geolocation ar geospatial information in the Fusion UI?

not that I know of, unlikely to happen in the short/mid term.

Vincent

Userlevel 2
Badge +3

Thanks @Vincent Gay .

I sure hope that some funtionality for handling geodata in CDF will preserved and further developed/maintained, even though Geospatial’s future is uncertain!


Assigning assets to features work fine, but I struggle to find a working syntax for retrieving the coordinates of one specific asset. Take as example the piece below, which works to lists the three features that match the constraint given by “stContains".

client.geospatial.list_features(
feature_type_external_id="land_test_ft",
filter={
"stContains": {
"property": "outline",
"value": {"wkt": "Point(9 60)"}
},
#"containsAny": {
# "property": "assetIds",
# "value": [my_asset_id]
#}
}
)

But when I uncomment the four lines with the “containsAny” constraint as suggested by the documentation https://developer.cognite.com/dev/concepts/resource_types/geospatial/#searching-for-features,
I get a not very helpful error in return:

Additional error info: { "invalid": [ "{\"containsAny\":{\"property\":\"assetIds\",\"value\":[540948440724148]}}" ] }

 

I see that I could do client-side filtering using geopandas or other options, to find the geodata for the specific asset. But I would think that it is more efficient to filter on assets in CDF first. I’m probably missing something here, and would appreciate a hint on where to find more information :)

Hi Kristian

I think you just spotted a error in the documentation!

Indeed the error message does not help pinpointing precisely to the problem: `value` should be `values`

Also note that you can control what properties are returned with something like:

 

"output": {
"properties": {
"externalId": {}
"assetIds": {}
  …
}
}

 

This can really speed up things if your geometries are large.

Hope this helps!

Vincent

Reply