-
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.
- Loading branch information
Showing
13 changed files
with
748 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import stac_geoparquet | ||
import json | ||
from pathlib import Path | ||
from pyarrow import Table | ||
from pystac_client import Client | ||
|
||
root = Path(__file__).parents[1] | ||
examples = root / "stac-arrow" / "examples" | ||
if not examples.is_dir(): | ||
examples.mkdir(parents=True) | ||
|
||
client = Client.open("https://planetarycomputer.microsoft.com/api/stac/v1") | ||
item_search = client.search( | ||
max_items=10, | ||
collections=["sentinel-2-l2a"], | ||
intersects={ | ||
"type": "Point", | ||
"coordinates": [-105.10, 40.17], | ||
"sortby": "-properties.datetime", | ||
}, | ||
) | ||
items = list(item_search.items_as_dicts()) | ||
batches = stac_geoparquet.arrow.parse_stac_items_to_arrow(items) | ||
table = Table.from_batches(batches) | ||
for version in ["1.0.0", "1.1.0"]: | ||
path = examples / f"sentinel-2-l2a-{version}.parquet" | ||
stac_geoparquet.arrow.to_parquet(table, path, schema_version=version) | ||
with open(examples / "sentinel-2-l2a.json", "w") as f: | ||
json.dump(items, f) |
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
pyarrow | ||
pystac-client | ||
stac-api-validator | ||
git+https://github.com/stac-utils/stac-geoparquet@e13f237 |
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,17 @@ | ||
[package] | ||
name = "stac-arrow" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[features] | ||
parquet = ["geoarrow/parquet"] | ||
parquet-compression = ["geoarrow/parquet_compression"] | ||
|
||
[dependencies] | ||
arrow = "52" | ||
arrow-cast = "52" | ||
geoarrow = { git = "https://github.com/geoarrow/geoarrow-rs", rev = "6fd07d5555f03b113a5cd36c7bf71c1a7cec8579" } | ||
geojson = "0.24" | ||
serde_json = "1" | ||
stac = { version = "0.7", path = "../stac" } | ||
thiserror = "1" |
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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,33 @@ | ||
use thiserror::Error; | ||
|
||
/// Crate-specific error enum. | ||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
/// [arrow::error::ArrowError] | ||
#[error(transparent)] | ||
Arrow(#[from] arrow::error::ArrowError), | ||
|
||
/// The bounding box is not a mapping. | ||
#[error("bbox is not a map: {0:?}")] | ||
BBoxIsNotAMap(serde_json::Value), | ||
|
||
/// [geoarrow::error::GeoArrowError] | ||
#[error(transparent)] | ||
GeoArrow(#[from] geoarrow::error::GeoArrowError), | ||
|
||
/// An invalid bbox mapping. | ||
#[error("invalid bbox mapping: {0:?}")] | ||
InvalidBBoxMap(serde_json::Map<String, serde_json::Value>), | ||
|
||
/// [std::io::Error] | ||
#[error(transparent)] | ||
Io(#[from] std::io::Error), | ||
|
||
/// [serde_json::Error] | ||
#[error(transparent)] | ||
SerdeJson(#[from] serde_json::Error), | ||
|
||
/// [stac::Error] | ||
#[error(transparent)] | ||
Stac(#[from] stac::Error), | ||
} |
Oops, something went wrong.