Expand description
Reader module, contains the definitions of the types that a user should use to read a file
§Reader
The Reader is the struct that actually reads the different files that make up a shapefile.
§Examples
When reading from a file:
Creates a reader from a path, then iterate over its Shapes
, reading one shape each iteration
let mut reader = shapefile::Reader::from_path("tests/data/multipatch.shp")?;
for shape_record in reader.iter_shapes_and_records() {
let (shape, record) = shape_record?;
println!("{}", shape);
}
§ShapeReader
If you only care about the geometries stored in the .shp file, whether or not the .dbf file actually exists, you can use the ShapeReader.
§Extra
If you know beforehand the exact type that the .shp file is made of,
you can use the different *_as::<S>()
methods.:
-
Reader::read_as To read all the shapes and records as the specified types using a Reader
-
Reader::iter_shapes_and_records_as To iterate over both the shapes and records of the Reader
-
ShapeReader::read_as To read all the shapes (only) as the specified type using ShapeReader
-
ShapeReader::iter_shapes_as To iterate over the shapes as shapes of the specified type using ShapeReader
Otherwise use the functions that return Shapes and do a match
§One liners
Some ‘one liner’ functions are provided to read the content of a shapefile with one line of code
Structs§
- Reader that reads a shapefile.
- Struct that handle iteration over the shapes of a .shp file
- This reader only reads the
.shp
and optionally the (.shx
) files of a shapefile.
Functions§
- Function to read all the Shapes in a file.
- Function to read all the Shapes in a file as a certain type