StarThrower.Gis.EsriLibrary
2.0.0
dotnet add package StarThrower.Gis.EsriLibrary --version 2.0.0
NuGet\Install-Package StarThrower.Gis.EsriLibrary -Version 2.0.0
<PackageReference Include="StarThrower.Gis.EsriLibrary" Version="2.0.0" />
<PackageVersion Include="StarThrower.Gis.EsriLibrary" Version="2.0.0" />
<PackageReference Include="StarThrower.Gis.EsriLibrary" />
paket add StarThrower.Gis.EsriLibrary --version 2.0.0
#r "nuget: StarThrower.Gis.EsriLibrary, 2.0.0"
#:package StarThrower.Gis.EsriLibrary@2.0.0
#addin nuget:?package=StarThrower.Gis.EsriLibrary&version=2.0.0
#tool nuget:?package=StarThrower.Gis.EsriLibrary&version=2.0.0
StarThrower.Gis.EsriLibrary
Read and write ESRI shapefile format (.shp/.dbf) including support for points, polylines, polygons, and multipart shapes.
StarThrower.Gis.EsriLibrary provides ShapeFile, a high-level wrapper that pairs a .shp
geometry file with its companion .dbf attribute table (via
StarThrower.XBase) and exposes them as a single set of
records — each combining an attribute Record with a
StarThrower.Gis.GeoUtilities.Shapes.Shape
geometry.
Installation
dotnet add package StarThrower.Gis.EsriLibrary
Core Types
| Type | Description |
|---|---|
ShapeFile |
The main entry point. Opens, reads, writes, and saves a shapefile (.shp + .dbf pair); manages its field schema, records, and overall Extent. Implements IDisposable. |
ShapeType |
Enumerates the ESRI shapefile geometry types: NullShape, Point, PolyLine, Polygon, MultiPoint, and their Z/M/Multipatch variants, with values matching the .shp format specification. |
Field |
Describes a single attribute field's schema: Name, Type (Types.FieldType), Length, and DecimalCount. Implements ICloneable. |
Record |
A single feature: an attribute data dictionary (set/get via SetData/GetData overloads by field name) plus a GetShape()/SetShape() geometry (StarThrower.Gis.GeoUtilities.Shapes.Shape). |
Field Types (Types namespace)
| Type | Code | Description |
|---|---|---|
StringField |
C |
Character data. Wraps StarThrower.XBase.StringField. |
NumericField |
N |
Numeric data (Int64 if DecimalCount is 0, otherwise double). Wraps StarThrower.XBase.NumericField. |
FloatField |
F |
Floating-point data. Wraps StarThrower.XBase.FloatField. |
DateField |
D |
Date data (yyyyMMdd). Wraps StarThrower.XBase.DateField. |
BooleanField |
L |
Logical (T/F) data. Wraps StarThrower.XBase.BooleanField. |
MemoField |
M |
Memo field reference. Wraps StarThrower.XBase.MemoField. |
UndefinedField |
U |
Placeholder for an unrecognized field type. Wraps StarThrower.XBase.UndefinedField. |
Types.FieldType is an abstract base deriving from StarThrower.XBase.FieldType; each concrete
type delegates MinLength/MaxLength, MinDecimalCount/MaxDecimalCount,
IsValidLength/IsValidDecimalCount/IsValidData, and Translate to the corresponding
StarThrower.XBase field type, so validation and on-disk representation match the underlying
.dbf exactly.
Usage
using StarThrower.Gis.EsriLibrary;
using StarThrower.Gis.EsriLibrary.Types;
using StarThrower.Gis.GeoUtilities.Shapes;
// Create a new point shapefile and define its attribute schema
using ShapeFile shapeFile = new ShapeFile();
shapeFile.ShapeType = ShapeType.Point;
shapeFile.AddField(new Field { Name = "NAME", Type = new StringField(), Length = 30 });
shapeFile.AddField(new Field { Name = "POP", Type = new NumericField(), Length = 9 });
// Add a record
Record record = shapeFile.CreateNewRecord();
record.SetShape(new PointShape(-77.0365, 38.8977));
record.SetData("NAME", "Washington, DC");
record.SetData("POP", 689545L);
shapeFile.AddRecord(record);
shapeFile.SaveAs(@"cities.shp"); // writes cities.shp and cities.dbf
// Read records back
shapeFile.Open(@"cities.shp", FileMode.Open, FileAccess.Read);
for (int i = 0; i < shapeFile.RecordCount; i++)
{
Record r = shapeFile.GetRecord(i);
PointShape point = (PointShape)r.GetShape();
string name = (string)r.GetData("NAME")!;
}
Exporting to XML
using StarThrower.Gis.GeoUtilities.Formatting;
string fileWiseXml = shapeFile.ToXml(XmlFormat.FileWise); // separate geography/data sections
string layerWiseXml = shapeFile.ToXml(XmlFormat.LayerWise); // combined geography+data per record
LoadXml(XmlDocument, XmlFormat) reads the LayerWise format back (schema, extent, and field
definitions). See Known Limitations below for Gml, ToJson/LoadJson,
and other unimplemented paths.
Usage Notes
- Opening a shapefile.
Open/SaveAstake the.shppath; the companion.dbfis derived by replacing the extension and opened/saved alongside it.OpenthrowsInvalidDataExceptionif the.shpand.dbfrecord counts don't match. AddRecordvalidatesShapeType. ARecord's shape must match theShapeFile'sShapeType, orAddRecordthrowsArgumentException.- Field type round-tripping.
Field/Types.FieldTypemirrorStarThrower.XBase'sXBaseField/FieldTypeexactly — internal conversion helpers translate between the two so the.dbfwritten alongside the.shpis a standard dBASE III file. - Geometry types.
ShapeTypevalues map one-to-one toStarThrower.Gis.GeoUtilities.Shapes.ShapeTypevalues;CreateNewRecord()returns aRecordpre-populated with the matchingShapes.Shapesubtype (e.g.PointShape,PolygonShape,PolylineZShape) for the shapefile'sShapeType.
Known Limitations
- Only four shape types fully read and write geometry.
NullShape,Point,PolyLine, andPolygonare fully implemented. The other tenShapeTypevalues —MultiPoint,PointZ,PolyLineZ,PolygonZ,MultiPointZ,PointM,PolyLineM,PolygonM,MultiPointM, andMultiPatch— throwNotImplementedExceptionas soon as a record of that shape type is added viaShapeFile.AddRecord. See issues #17–#26. .prjprojection files can be read but not written. Reading resolves the British National Grid and all WGS72/WGS84 UTM zones from a.prjfile'sPROJCSname, butShapeFile.Save/SaveAsnever write projection data back out — the underlying write path is unimplemented. See #16.AlterRecord,ToJson, andLoadJsonare unimplemented stubs that throwNotImplementedException.ToXml(XmlFormat.Gml)andLoadXmlwithXmlFormat.GmlorXmlFormat.FileWisesilently produce no output rather than throwing. See #34 and #35.
Dependencies
StarThrower.ByteUtilities— endian-aware byte conversions used internally for.shp/.shxbinary record headers and geometry data.StarThrower.Gis.GeoUtilities—Shapesgeometry types,GeoRectangle, and XML formatting (XmlFormat).StarThrower.StringUtilities— XML encoding and string padding helpers.StarThrower.XBase— the.dbfattribute table read/write implementation underlyingShapeFile's field and record support.
License
Copyright © 2026 Stephen Elmer. Licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- StarThrower.ByteUtilities (>= 2.0.0)
- StarThrower.Gis.GeoUtilities (>= 2.0.0)
- StarThrower.StringUtilities (>= 2.0.0)
- StarThrower.XBase (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 94 | 7/4/2026 |