shapekit library

A comprehensive Dart library for reading and writing ESRI Shapefiles and GeoPackage files with unified domain entities.

Shapefile Usage

import 'package:shapekit/shapekit.dart';

final shapefile = Shapefile();
shapefile.read('path/to/file.shp');
for (final record in shapefile.records) {
  if (record is Point) print('Point at ${record.x}, ${record.y}');
}

GeoPackage Usage

final conn = GpkgReader.open('path/to/file.gpkg');
await for (final batch in conn.queryFeatures(
  table: 'layer',
  bounds: Envelope(-10, 40, 10, 50),
)) {
  for (final feature in batch.features) {
    if (feature.geometry is Point) {
      final p = feature.geometry as Point;
      print('Point at ${p.x}, ${p.y}');
    }
  }
}

Classes

ColumnDef
Column definition for explicit schema in GpkgWriter.addFeatureTable.
ColumnInfo
Metadata about a table column discovered via PRAGMA table_info.
CrsInfo
CRS information extracted from a GeoPackage's spatial reference system table.
CShapeProjectionFile
Handles reading projection information from .prj files
DbaseField
Represents a field definition in a dBASE file
DbaseFile
Envelope
Axis-aligned bounding box shared across all format implementations.
EnvelopeM
Bounding box with optional M (measure) values.
EnvelopeZ
Bounding box with Z coordinates and optional M values.
FeatureBatch
A batch of decoded features from a spatial query
FeatureTableMetadata
Metadata about a feature table.
GeoFeature
A decoded GeoPackage feature with typed geometry and optional attributes
GpkgReader
Represents a connection to a GeoPackage file
GpkgTableWriter
Streaming writer for bulk row insertion into a GeoPackage feature table.
GpkgWriter
Creates and writes GeoPackage files.
MultiPatch
MultiPoint
MultiPointM
MultiPointM has optional M values per ESRI spec
MultiPointZ
MultiPointZ has required Z values and optional M values per ESRI spec
Point
Represents a 2D point geometry (X, Y coordinates)
PointM
Represents a 2D point with measure value (X, Y, M coordinates)
PointZ
Represents a 3D point with Z and M values (X, Y, Z, M coordinates)
Polygon
PolygonM
PolygonZ
Polyline
PolylineM
PolylineM has optional M values per ESRI spec
PolylineZ
PolylineZ has required Z values and optional M values per ESRI spec
RawFeatureBatch
A batch of raw features returned by GpkgReader.queryFeaturesInBounds.
Record
Base class for all shapefile geometry records
Shapefile
Main class for reading and writing ESRI Shapefiles
ShapefileFeature
ShapefileStreamReader
ShapeHeader
Represents the header of a shapefile (.shp or .shx file)
ShapeOffset
Represents the offset and length of a record in a shapefile
ShapeType
Represents a shapefile geometry type
SpatialIndex
WkbDecoder
Decodes GeoPackage WKB (GPKG-WKB) geometries into flat Float32List coordinates.
WkbEncoder
Encodes coordinates into GPKG-WKB blobs (inverse of WkbDecoder).

Enums

GeometryType
Simple geometry categorization for convenience
ShapefileErrorType
Exception types for shapefile operations

Extensions

GeometryTypeExtension on GeometryType
Extension with factory methods to convert from various type representations
PolygonHolesExtension on Polygon
Extension providing ring and hole utilities for Polygon geometries.
PolygonMHolesExtension on PolygonM
Extension providing ring and hole utilities for PolygonM geometries.
PolygonZHolesExtension on PolygonZ
Extension providing ring and hole utilities for PolygonZ geometries.
ShapefileExtensions on Shapefile

Exceptions / Errors

CorruptedDataException
Exception thrown when record data is corrupted
FileNotFoundException
Exception thrown when a file cannot be found or accessed.
GpkgException
InvalidBoundsException
Exception thrown when bounding box is invalid
InvalidFormatException
Exception thrown when file format is invalid
InvalidHeaderException
Exception thrown when file header is invalid
ShapefileException
Base exception class for shapefile operations
ShapefileIOException
Exception thrown when I/O operation fails
UnsupportedTypeException
Exception thrown when geometry type is not supported