Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
GeoZero
Zero-Copy reading and writing of geospatial data.
GeoZero defines an API for reading geospatial data formats without an intermediate representation. It defines traits which can be implemented to read and convert to an arbitrary format or render geometries directly.
Supported geometry types:
- OGC Simple Features
- Circular arcs as defined by SQL-MM Part 3
- TIN
Supported dimensions: X, Y, Z, M, T
Available implementations
| Format | Read | Write | Notes |
|---|---|---|---|
| GeoJSON | ✅ | ✅ | |
| GEOS | ✅ | ✅ | |
| GDAL | ✅ | ✅ | |
| WKB | ✅ | ✅ | Supports PostGIS geometries for rust-postgres, SQLx and Diesel. And also supports GeoPackage geometries for SQLx. |
| WKT | ✅ | ✅ | |
| CSV | ✅ | ✅ | |
| SVG | ❌ | ✅ | |
| geo-types | ✅ | ✅ | |
| MVT (Mapbox Vector Tiles) | ✅ | ✅ | |
| GPX | ✅ | ❌ | |
| Shapefile | ✅ | ❌ | |
| FlatGeobuf | ✅ | ❌ | Available via the flatgeobuf crate. |
| GeoArrow | ✅ | ✅ | Available via the geoarrow crate. |
| GeoParquet | ✅ | ✅ | Available via the geoarrow crate. |
Conversion API
Convert a GeoJSON polygon to geo-types and calculate centroid:
let geojson = GeoJson;
if let Ok = geojson.to_geo
Full source code: geo_types.rs
Convert GeoJSON to a GEOS prepared geometry:
let geojson = GeoJson;
let geom = geojson.to_geos.expect;
let prepared_geom = geom.to_prepared_geom.expect;
let geom2 = new_from_wkt.expect;
assert_eq!;
Full source code: geos.rs
Read FlatGeobuf subset as GeoJSON:
let mut file = new;
let mut fgb = open?.select_bbox?;
println!;
Full source code: geojson.rs
PostGIS usage examples
Select and insert geo-types geometries with rust-postgres. Requires the with-postgis-postgres feature:
let mut client = connect?;
let row = client.query_one?;
let value: Decode = row.get;
if let Some = value.geometry
// Insert geometry
let geom: Geometry = new.into;
let _ = client.execute;
Select and insert geo-types geometries with SQLx. Requires the with-postgis-sqlx feature:
let pool = new
.max_connections
.connect
.await?;
let row: =
query_as
.fetch_one
.await?;
let value = row.0;
if let Some = value.geometry
// Insert geometry
let geom: Geometry = new.into;
let _ = query
.bind
.execute
.await?;
Using compile-time verification requires type overrides:
let _ = query!
.execute
.await?;
let rec = query_as!
.fetch_one
.await?;
assert_eq!;
Full source code: postgis.rs
Processing API
Count vertices of an input geometry:
;
let mut vertex_counter = VertexCounter;
geometry.process?;
Full source code: geozero-api.rs
Find maximal height in 3D points:
;
let mut max_finder = MaxHeightFinder;
points.process_geom?;
assert_eq!;
Full source code: geozero-api.rs
Render polygons:
Full source code: flatgeobuf-gpu
Read a FlatGeobuf dataset with async HTTP client applying a bbox filter and convert to GeoJSON:
let url = "https://flatgeobuf.org/test/data/countries.fgb";
let mut fgb = open
.await?
.select_bbox
.await?;
let mut fout = new;
let mut json = new;
fgb.process_features.await?;
Full source code: geojson.rs
Create a KD-tree index with kdbush:
let mut points = PointIndex ;
read_geojson_geom?;
points.index.build_index;
Full source code: kdbush.rs
Dependencies
# Ubuntu/Debian/Mint