Skip to content

Commit

Permalink
Merge pull request #12 from sertit/fix/convert_GML_from_s3_with_ogr2ogr
Browse files Browse the repository at this point in the history
Fix: Convert a GML file from S3 path to geojson withogr2ogr
  • Loading branch information
remi-braun authored Mar 13, 2024
2 parents 1d90f3a + 7c3dc95 commit 0de38aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.36.1 (2024-xx-xx)

- FIX: Fix `vector._read_vector_core` when we convert a GML file from S3 to geojson with ogr2ogr ([#12](https://github.com/sertit/sertit-utils/pull/12))
- FIX: Fix `files.extract_file` when there is a file in the root of the zip archive ([#11](https://github.com/sertit/sertit-utils/pull/11))
- FIX: Fix `geometry.nearest_neighbors` when k is bigger than the number of candidates
- DOC: Update some examples in documentation
Expand Down
9 changes: 5 additions & 4 deletions sertit/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,6 @@ def _read_kml(
if not tmp_dir:
tmp_dir = tempfile.TemporaryDirectory()

# KML should be downloaded to work with ogr2ogr
if path.is_cloud_path(raw_path):
raw_path = AnyPath(raw_path).fspath

vect_path_gj = ogr2geojson(raw_path, tmp_dir.name, arch_path)
vect = gpd.read_file(vect_path_gj, **kwargs)
else:
Expand Down Expand Up @@ -655,6 +651,11 @@ def ogr2geojson(
assert shutil.which("ogr2ogr") # Needs ogr2ogr here

out_dir = str(out_dir)

# vector_path should be downloaded to work with ogr2ogr
if path.is_cloud_path(vector_path):
vector_path = AnyPath(vector_path).fspath

vector_path = str(vector_path)
if vector_path.endswith(".zip"):
with zipfile.ZipFile(vector_path, "r") as zip_ds:
Expand Down

0 comments on commit 0de38aa

Please sign in to comment.