Skip to main content

Crate geonative_shapefile

Crate geonative_shapefile 

Source
Expand description

§geonative-shapefile

Pure-Rust reader for the Esri Shapefile family (.shp + .shx + .dbf

  • optional .prj / .cpg). No GDAL, no shapelib.

§What v0.1 covers

  • 2D shape types: Null, Point, Polyline, Polygon, MultiPoint
  • DBF field types: C (char), N (numeric), F (float), D (date), L (logical); other DBF types come through as Value::String or Null
  • Ring orientation flipped from Shapefile (CW outer / CCW hole) to OGC (CCW outer / CW hole) so polygons match the rest of the geonative IR
  • .shp is mmapped for bounded RAM usage on multi-GB inputs; .shx + .dbf are read into Vecs (small)

§v0.1 scope cuts

  • Z/M variants (PointZ, PolygonZ, MultipointZ, etc.) return Unsupported
  • MultiPatch (type 31) — surface-class geometry; defer
  • Non-UTF-8 codepages (.cpg / LDID full table) — defer; v0.1 treats string bytes as UTF-8 with replacement for invalid sequences
  • .qix / .sbn spatial index files — ignored
  • Sparse / corrupt-.shx repair — error rather than auto-rebuild

§Usage

let shp = geonative_shapefile::Shapefile::open("roads.shp")?;
println!("{} features, schema: {:?}", shp.feature_count(), shp.schema());
for f in shp.read() {
    let f = f?;
    // f.fid, f.geometry, f.attributes
}

Re-exports§

pub use dataset::FeatureIter;
pub use dataset::Shapefile;
pub use error::Result;
pub use error::ShpError;
pub use header::ShapeType;
pub use header::ShpHeader;

Modules§

bytes
Mixed-endianness byte primitives for the Esri Shapefile format.
dataset
Top-level public API: Shapefile, feature iterator.
dbf
dBASE III+/IV table reader for .dbf attribute sidecars.
error
Driver-specific error type for shapefile reading.
header
The 100-byte file header shared by .shp and .shx.
shape
Decode an individual shape record into a geonative_core::Geometry.
shx
.shx random-access index for the companion .shp.

Functions§

open
Convenience: open a .shp (or any file in the shapefile triad) and produce a Shapefile handle.