spotfiresoftware / spotfire-python

Package for Building Python Extensions to Spotfire®
Other
18 stars 6 forks source link

Geopandas 0.11.0 changes CRS handling #26

Closed bbassett-tibco closed 2 years ago

bbassett-tibco commented 2 years ago

Geopandas just released 0.11.0 today, and is now causing unit test failures:

ERROR [0.025s]: test_read_write_geodata (spotfire.test.test_sbdf.SbdfTest)
Test that geo-encoded data is properly converted to/from GeoDataFrame
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/spotfire-python/spotfire-python/spotfire/test/test_sbdf.py", line 129, in test_read_write_geodata
    sbdf.export_data(gdf, tempdir + "\\test.sbdf")
  File "/home/runner/work/spotfire-python/spotfire-python/spotfire/sbdf.py", line 162, in export_data
    columns, column_names, column_types, table_metadata, column_metadata = _export_columnize_data(obj,
  File "/home/runner/work/spotfire-python/spotfire-python/spotfire/sbdf.py", line 204, in _export_columnize_data
    obj = _geo_data_frame_to_data_frame(obj, table_metadata, column_metadata)
  File "/home/runner/work/spotfire-python/spotfire-python/spotfire/sbdf.py", line 1484, in _geo_data_frame_to_data_frame
    if gdf.crs is not None:
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pandas/core/generic.py", line 5575, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'crs'

Looking at the changelog for the release (https://github.com/geopandas/geopandas/releases/tag/v0.11.0), it appears that there are a number of CRS changes and deprecations. Find and fix support for this new release.

bbassett-tibco commented 2 years ago

Looks like the new release changed the way the gdf.crs member is accessed if the geometry column is missing (like when we're transforming gdf during the export_data call). Modified the logic to save the CRS object before dropping the geometry column so that we can reference it when attaching table metadata.