NCPP / ocgis

OpenClimateGIS is a set of geoprocessing and calculation tools for CF-compliant climate datasets.
Other
70 stars 21 forks source link

`get_fiona_type_from_pydata` does not support lists #512

Closed huard closed 4 years ago

huard commented 4 years ago

Sometimes in the properties field of a geometry, there is a bbox field with a list of values. Lists are not supported by get_fiona_type_from_pydata.

bekozi commented 4 years ago

It should be relatively trivial to detect if pydata is a sequence and use the first element as an archetype. Would this address the issue? I don't have a good sense for the context.

huard commented 4 years ago

I don't know. I just noticed that some properties with list crashed this function, but I don't know what role it plays exactly.

So I'm fetching geometries from a WFS server and load them as shapely objects (geom) with crs and properties. I then pass those geometries as a list of dict to OcgOperations.

For the moment I just replaced the properties whose values are a list by a string with an error message. Any improvement over this makeshift solution is going to be welcome.

bekozi commented 4 years ago

Got it. I'll take a look and get back to you. Thanks for the additional info.

bekozi commented 4 years ago

@huard: Since fiona properties are always scalars and from_records expects this, I can think of a few options:

Which do you think works best for your case?

huard commented 4 years ago

No strong opinion, I'm happy with the first and simplest option.

bekozi commented 4 years ago

Okay, pushed a fix to master. Let me know how it goes. A warning is just issued for a list/tuple in properties.

bekozi commented 4 years ago

@huard, I realized I needed to mention that the property is skipped in addition to emitting a warning! Oops.

huard commented 4 years ago

Looking good. Thanks !