Skip to content

Commit

Permalink
Fix: kwargs not passed on to OGR in write_dataframe (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
theroggy authored Apr 4, 2022
1 parent 22f6878 commit 0c1f351
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

- use dtype `object` instead of `numpy.object` to eliminate deprecation warnings (#34)
- raise error if layer cannot be opened (#35)
- fix passing gdal creation parameters in `write_dataframe` (#62)

## 0.3.0

Expand Down
1 change: 1 addition & 0 deletions pyogrio/geopandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,5 @@ def write_dataframe(df, path, layer=None, driver=None, encoding=None, **kwargs):
crs=crs,
geometry_type=geometry_type,
encoding=encoding,
**kwargs
)
16 changes: 16 additions & 0 deletions pyogrio/tests/test_geopandas_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,22 @@ def test_write_empty_dataframe(tmpdir, driver, ext):
assert_geodataframe_equal(df, expected)


def test_write_dataframe_gdalparams(tmpdir, naturalearth_lowres):
original_df = read_dataframe(naturalearth_lowres)

test_noindex_filename = os.path.join(str(tmpdir), f"test_gdalparams_noindex.shp")
write_dataframe(original_df, test_noindex_filename, SPATIAL_INDEX="NO")
assert os.path.exists(test_noindex_filename) is True
test_noindex_index_filename = os.path.join(str(tmpdir), f"test_gdalparams_noindex.qix")
assert os.path.exists(test_noindex_index_filename) is False

test_withindex_filename = os.path.join(str(tmpdir), f"test_gdalparams_withindex.shp")
write_dataframe(original_df, test_withindex_filename, SPATIAL_INDEX="YES")
assert os.path.exists(test_withindex_filename) is True
test_withindex_index_filename = os.path.join(str(tmpdir), f"test_gdalparams_withindex.qix")
assert os.path.exists(test_withindex_index_filename) is True


@pytest.mark.filterwarnings(
"ignore: You will likely lose important projection information"
)
Expand Down

0 comments on commit 0c1f351

Please sign in to comment.