bcgov / FIT_changedetector

Compare two sets of geodata, reporting on various types of differences
Apache License 2.0
2 stars 0 forks source link

support non-spatial data #7

Closed smnorris closed 1 month ago

smnorris commented 1 month ago

csv/gdb tables etc

smnorris commented 1 month ago

see related #8 - does output to .gdb always make sense for csv/other formats?

smnorris commented 1 month ago

Writing non-spatial to gdb with geopandas /pyogrio does not seem to be supported? Note that .gpkg works fine.

$ changedetector compare tests/data/pets_1.csv tests/data/pets_2.csv -pk id
Index(['name', 'colour', 'status'], dtype='object')
Index(['name', 'colour', 'status', 'geometry'], dtype='object')
/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/pyogrio/raw.py:698: UserWarning: 'crs' was not provided.  The output dataset will not have projection information defined and may not be usable in other systems.
  warnings.warn(
Traceback (most recent call last):
  File "pyogrio/_io.pyx", line 2183, in pyogrio._io.create_ogr_dataset_layer
  File "pyogrio/_err.pyx", line 183, in pyogrio._err.exc_wrap_pointer
pyogrio._err.CPLE_NotSupportedError: Unsupported geometry type

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/bin/changedetector", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/fit_changedetector/src/fit_changedetector/cli.py", line 326, in compare
    diff[key].to_file(out_gdb, driver="OpenFileGDB", layer=key, mode=mode)
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/geopandas/geodataframe.py", line 1536, in to_file
    _to_file(self, filename, driver, schema, index, **kwargs)
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/geopandas/io/file.py", line 686, in _to_file
    _to_file_pyogrio(df, filename, driver, schema, crs, mode, metadata, **kwargs)
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/geopandas/io/file.py", line 748, in _to_file_pyogrio
    pyogrio.write_dataframe(df, filename, driver=driver, metadata=metadata, **kwargs)
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/pyogrio/geopandas.py", line 654, in write_dataframe
    write(
  File "/Users/snorris/Projects/repo/fit_changedetector/.venv/lib/python3.12/site-packages/pyogrio/raw.py", line 709, in write
    ogr_write(
  File "pyogrio/_io.pyx", line 2298, in pyogrio._io.ogr_write
  File "pyogrio/_io.pyx", line 2197, in pyogrio._io.create_ogr_dataset_layer
pyogrio.errors.DataLayerError: Unsupported geometry type