diff --git a/telluric/collections.py b/telluric/collections.py index bfe1d77..7277a54 100644 --- a/telluric/collections.py +++ b/telluric/collections.py @@ -325,9 +325,11 @@ def save(self, filename, driver=None, schema=None): crs = self.crs # https://github.com/rasterio/rasterio/issues/2453 - crs = crs.to_dict() + # https://github.com/rasterio/rasterio/issues/3282 (to_dict() is lossy in rasterio) + # We should switch to fiona 1.9.x and convert to fiona.crs.CRS + crs_wkt = crs.to_wkt() - with fiona.open(filename, 'w', driver=driver, schema=schema, crs=crs) as sink: + with fiona.open(filename, 'w', driver=driver, schema=schema, crs_wkt=crs_wkt) as sink: for feature in self: new_feature = self._adapt_feature_before_write(feature) sink.write(new_feature.to_record(crs)) diff --git a/tests/test_collections.py b/tests/test_collections.py index 8c862ca..daa3f9f 100644 --- a/tests/test_collections.py +++ b/tests/test_collections.py @@ -362,7 +362,7 @@ def test_feature_collection_with_dates_serializes_correctly(): with tempfile.TemporaryDirectory() as path: file_path = os.path.join(path, "test_dates.shp") with fiona.open( - file_path, mode='w', driver="ESRI Shapefile", schema=schema, crs=feature.crs.to_dict() + file_path, mode='w', driver="ESRI Shapefile", schema=schema, crs_wkt=feature.crs.to_wkt() ) as sink: sink.write(mapping(feature))