Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDAL 3.5 compat; Empty lists are not written to GeoJSON? #97

Open
caspervdw opened this issue Aug 22, 2022 · 0 comments
Open

GDAL 3.5 compat; Empty lists are not written to GeoJSON? #97

caspervdw opened this issue Aug 22, 2022 · 0 comments

Comments

@caspervdw
Copy link
Collaborator

caspervdw commented Aug 22, 2022

There is an issue having to do with writing "list" properties in the GeoJSON driver (fiona / GDAL)

Looking at the testenv, it seems to be caused by GDAL 3.5. Tests with Gdal 3.4 (and the same Fiona) do not have the error. As I have GDAL 3.4 locally I am unable to reproduce this.

The issue is that the record to be written has fields ['str', 'dct', 'float', 'int'] while the existing schema (derived from the first file) has fields ['int', 'str', 'lst', 'dct', 'float']. I think empty lists are not written with the GDAL 3.5 GeoJSON driver anymore (see commit 0c39dfd)

____________________ TestGeometryFileSink.test_merge_files _____________________

self = <dask_geomodeling.tests.test_geometry_sinks.TestGeometryFileSink testMethod=test_merge_files>

    def test_merge_files(self):
        block = self.klass(self.source, self.path, "geojson")
        block.get_data(**self.request)
        block.get_data(**self.request_2)
    
        assert len(os.listdir(self.path)) == 2
        filename = os.path.join(self.root, "combined.geojson")
>       sinks.GeometryFileSink.merge_files(self.path, filename)

dask_geomodeling/tests/test_geometry_sinks.py:191: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
dask_geomodeling/geometry/sinks.py:208: in merge_files
    out.writerecords(v for k, v in source.items())
/usr/share/miniconda/envs/test/lib/python3.10/site-packages/fiona/collection.py:361: in writerecords
    self.session.writerecs(records, self)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   ValueError: Record does not match collection schema: odict_keys(['str', 'dct', 'float', 'int']) != ['int', 'str', 'lst', 'dct', 'float']

fiona/ogrext.pyx:1280: ValueError
------------------------------ Captured log call -------------------------------
WARNING  fiona.ogrext:sinks.py:208 Skipping field lst: invalid type 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant