Repository navigation
IRI.Maptor.Sta.ShapefileFormat Coordinate Systems
Hossein Narimani Rad edited this page Sep 28, 2025
·
3 revisions
The IRI.Maptor.Sta.ShapefileFormat library provides comprehensive support for coordinate systems and projections through the PRJ file format and built-in coordinate system definitions.
// Read shapefile with coordinate system
var shapes = await Shapefile.ReadShapesAsync("file.shp", "file.prj");
// Access coordinate system information
var coordinateSystem = shapes.CoordinateSystem;
Console.WriteLine($"Projection: {coordinateSystem.Name}");
Console.WriteLine($"WKT: {coordinateSystem.Wkt}");// From PRJ file
var coordSys = CoordinateSystem.FromPrjFile("projection.prj");
// From EPSG code
var wgs84 = CoordinateSystem.FromEpsgCode(4326);
var webMercator = CoordinateSystem.FromEpsgCode(3857);// WGS84 (EPSG:4326)
var wgs84 = CoordinateSystem.FromEpsgCode(4326);
// NAD83 (EPSG:4269)
var nad83 = CoordinateSystem.FromEpsgCode(4269);// Web Mercator (EPSG:3857)
var webMercator = CoordinateSystem.FromEpsgCode(3857);
// UTM Zone 10N (EPSG:32610)
var utm10N = CoordinateSystem.FromEpsgCode(32610);// Read shapefile in one coordinate system
var shapes = await Shapefile.ReadShapesAsync("input.shp", "input.prj");
// Transform to Web Mercator
var targetCoordSys = CoordinateSystem.FromEpsgCode(3857);
var transformedShapes = shapes.TransformTo(targetCoordSys);
// Write transformed shapes
await Shapefile.WriteShapesAsync(transformedShapes, "output.shp");// Transform from UTM to Geographic
var utmShapes = await Shapefile.ReadShapesAsync("utm_data.shp");
var geographicShapes = utmShapes.TransformTo(CoordinateSystem.FromEpsgCode(4326));
// Transform from Geographic to Web Mercator
var webMercatorShapes = geographicShapes.TransformTo(CoordinateSystem.FromEpsgCode(3857));- WGS84 (EPSG:4326)
- NAD83 (EPSG:4269)
- NAD27 (EPSG:4267)
- UTM Zone 1N-60N (EPSG:32601-32660)
- UTM Zone 1S-60S (EPSG:32701-32760)
- Web Mercator (EPSG:3857)
- Pseudo-Mercator (EPSG:3857)
- Various State Plane Coordinate Systems
- Lambert Conformal Conic
- Transverse Mercator
var coordSys = CoordinateSystem.FromEpsgCode(4326);
await coordSys.WritePrjFileAsync("output.prj");var customWkt = @"GEOGCS[""WGS 84"",DATUM[""WGS_1984"",SPHEROID[""WGS 84"",6378137,298.257223563]],PRIMEM[""Greenwich"",0],UNIT[""degree"",0.0174532925199433]]";
var coordSys = new CoordinateSystem("WGS 84", customWkt);try
{
var coordSys = CoordinateSystem.FromPrjFile("file.prj");
Console.WriteLine($"Valid coordinate system: {coordSys.Name}");
}
catch (InvalidCoordinateSystemException ex)
{
Console.WriteLine($"Invalid coordinate system: {ex.Message}");
}var shapes = await Shapefile.ReadShapesAsync("file.shp");
var boundingBox = shapes.GetBoundingBox();
// Check if coordinates are within expected range
if (boundingBox.MinX < -180 || boundingBox.MaxX > 180)
{
Console.WriteLine("Warning: X coordinates outside valid longitude range");
}// Coordinate systems are automatically cached
var coordSys1 = CoordinateSystem.FromEpsgCode(4326);
var coordSys2 = CoordinateSystem.FromEpsgCode(4326);
// coordSys1 and coordSys2 reference the same cached instance// For multiple transformations, use batch processing
var sourceCoordSys = CoordinateSystem.FromEpsgCode(4326);
var targetCoordSys = CoordinateSystem.FromEpsgCode(3857);
var transformedShapes = shapes
.AsParallel()
.Select(shape => shape.TransformTo(targetCoordSys))
.ToList();For more examples, see the Examples page
π Home
π IRI.Maptor.Sta.ShapefileFormat
Coming Soon
Coming Soon
Maptor Spatial Library Ecosystem