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

Fix: kwargs not passed on to OGR in write_dataframe #67

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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