-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: stac-geoparquet and stac-arrow
- Loading branch information
Showing
29 changed files
with
1,256 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
deepdiff | ||
pyarrow | ||
stac-geoparquet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# This file was autogenerated by uv via the following command: | ||
# uv pip compile scripts/requirements-stac-geoparquet.in | ||
certifi==2024.7.4 | ||
# via | ||
# pyogrio | ||
# pyproj | ||
ciso8601==2.3.1 | ||
# via stac-geoparquet | ||
deepdiff==7.0.1 | ||
# via -r scripts/requirements-stac-geoparquet.in | ||
deltalake==0.18.2 | ||
# via stac-geoparquet | ||
geopandas==1.0.1 | ||
# via stac-geoparquet | ||
numpy==2.0.1 | ||
# via | ||
# geopandas | ||
# pandas | ||
# pyarrow | ||
# pyogrio | ||
# shapely | ||
ordered-set==4.1.0 | ||
# via deepdiff | ||
orjson==3.10.6 | ||
# via stac-geoparquet | ||
packaging==24.1 | ||
# via | ||
# geopandas | ||
# pyogrio | ||
# stac-geoparquet | ||
pandas==2.2.2 | ||
# via | ||
# geopandas | ||
# stac-geoparquet | ||
pyarrow==17.0.0 | ||
# via | ||
# -r scripts/requirements-stac-geoparquet.in | ||
# deltalake | ||
# stac-geoparquet | ||
pyarrow-hotfix==0.6 | ||
# via deltalake | ||
pyogrio==0.9.0 | ||
# via geopandas | ||
pyproj==3.6.1 | ||
# via | ||
# geopandas | ||
# stac-geoparquet | ||
pystac==1.10.1 | ||
# via stac-geoparquet | ||
python-dateutil==2.9.0.post0 | ||
# via | ||
# pandas | ||
# pystac | ||
pytz==2024.1 | ||
# via pandas | ||
shapely==2.0.5 | ||
# via | ||
# geopandas | ||
# stac-geoparquet | ||
six==1.16.0 | ||
# via python-dateutil | ||
stac-geoparquet==0.6.0 | ||
# via -r scripts/requirements-stac-geoparquet.in | ||
tzdata==2024.1 | ||
# via pandas |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python | ||
|
||
import json | ||
import sys | ||
import shutil | ||
import subprocess | ||
import tempfile | ||
from typing import Any | ||
from deepdiff import DeepDiff | ||
from pathlib import Path | ||
import pyarrow.parquet | ||
import stac_geoparquet.arrow | ||
import pyarrow | ||
|
||
root = Path(__file__).parents[1] | ||
path = root / "spec-examples" / "v1.0.0" / "extended-item.json" | ||
directory = tempfile.mkdtemp() | ||
parquet_path = Path(directory) / "extended-item.parquet" | ||
|
||
def clean_report(report: dict[str, Any]) -> dict[str, Any]: | ||
"""We expect datetime values to be changed in the report.""" | ||
if report.get("values_changed"): | ||
if report["values_changed"].get("root['properties']['datetime']") == { | ||
"new_value": "2020-12-14T18:02:31.437Z", | ||
"old_value": "2020-12-14T18:02:31.437000Z", | ||
}: | ||
del report["values_changed"]["root['properties']['datetime']"] | ||
if not report["values_changed"]: | ||
del report["values_changed"] | ||
return report | ||
|
||
try: | ||
# Writing | ||
subprocess.check_call( | ||
["cargo", "run", "--no-default-features", "--", "translate", path, parquet_path] | ||
) | ||
table = pyarrow.parquet.read_table(parquet_path) | ||
after = next(stac_geoparquet.arrow.stac_table_to_items(table)) | ||
with open(path) as f: | ||
before = json.load(f) | ||
report = DeepDiff(before, after).to_dict() | ||
report = clean_report(report) | ||
if report: | ||
print(json.dumps(report, indent=2)) | ||
sys.exit(1) | ||
else: | ||
parquet_path.unlink() | ||
|
||
# Reading | ||
table = stac_geoparquet.arrow.parse_stac_items_to_arrow([before]) | ||
stac_geoparquet.arrow.to_parquet(table, parquet_path) | ||
item_collection = json.loads(subprocess.check_output( | ||
["cargo", "run", "--no-default-features", "--", "translate", parquet_path] | ||
)) | ||
report = DeepDiff(before, item_collection["features"][0]).to_dict() | ||
report = clean_report(report) | ||
if report: | ||
print(json.dumps(report, indent=2)) | ||
sys.exit(1) | ||
|
||
finally: | ||
shutil.rmtree(directory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "stac-arrow" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
arrow-array = "52" | ||
arrow-cast = "52" | ||
arrow-schema = "52" | ||
arrow-json = "52" | ||
geoarrow = { git = "https://github.com/geoarrow/geoarrow-rs", rev = "476562b3da7dde9cd324fc5bf5ceb5451f76c451" } | ||
geojson = "0.24" | ||
geo-types = "0.7" | ||
serde_json = "1" | ||
stac = { version = "0.7", path = "../stac" } | ||
thiserror = "1" | ||
|
||
[dev-dependencies] | ||
geoarrow = { git = "https://github.com/geoarrow/geoarrow-rs", rev = "476562b3da7dde9cd324fc5bf5ceb5451f76c451", features = [ | ||
"parquet", | ||
] } | ||
stac-validate = { version = "0.1", path = "../stac-validate" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../spec-examples/v1.0.0 |
Binary file not shown.
Oops, something went wrong.