Skip to content

Commit f34fd7e

Browse files
committed
update readme with example
1 parent 9eb1ef5 commit f34fd7e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,35 @@ This crate provides representations of Esri JSON objects with [`serde::Deseriali
99
- `geo` implements `From` for the Esri JSON objects.
1010
- `geoarrow` provides compatibility with arrow and geoarrow by implementing geoarrow geometry traits as well as providing a utility function `featureset_to_arrow()` which converts a `FeatureSet` to an arrow `RecordBatch`.
1111

12+
## Example usage:
13+
14+
In this example, we query a feature service and convert the response to an Arrow `RecordBatch`. This requires the `geoarrow` feature to be enabled.
15+
16+
```rust
17+
use serde_esri::features::FeatureSet;
18+
use serde_esri::arrow_compat::featureset_to_arrow;
19+
20+
#[tokio::main]
21+
async fn main() {
22+
23+
// query url
24+
let furl = "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Counties_Generalized_Boundaries/FeatureServer/0/query?where=1=1&outFields=*&f=json&resultRecordCount=10";
25+
26+
// make the request
27+
let resp = reqwest::get(furl)
28+
.await.unwrap()
29+
.text()
30+
.await.unwrap();
31+
32+
// parse the response into a FeatureSet
33+
let fset: FeatureSet<2> = serde_json::from_str(&resp).unwrap();
34+
35+
// convert the FeatureSet to an Arrow RecordBatch
36+
let rb = featureset_to_arrow(fset).unwrap();
37+
38+
println!("{:#?}", rb.schema());
39+
}
40+
```
1241

1342
## Supported Esri JSON objects:
1443

0 commit comments

Comments
 (0)