Lightweight geospatial .NET library with geodesic support using Haversine and Vincenty algorithms.
$ dotnet add package SharpSpatialSharpSpatial is a lightweight geospatial library for .NET, built as a modern alternative to SqlGeography and SqlGeometry, with full support for .NET Core and custom geodesic calculations written entirely in C#.
It combines the power of NetTopologySuite, GeoAPI, and ProjNET4GeoAPI for planar operations, while offering accurate geodesic calculations (Haversine and Vincenty) and basic projection capabilities (Spherical Mercator).
While useful in many real-world applications, SharpSpatial is not a full GIS engine.
Here’s what it doesn’t do (yet):
Still, for many server-side or data-processing tasks, it offers exactly what’s needed — with minimal overhead.
Via NuGet:
dotnet add package SharpSpatial
using SharpSpatial;
// Prepare some WKT to parse
string squareWKT = "POLYGON((5 65, 25 65, 25 85, 5 85, 5 65))";
string pointH_WKT = "POINT(0 75)";
string pointV_WKT = "POINT(15 88)";
// Create a square and two points
SharpGeography square = new(squareWKT, 4326, false);
SharpGeography pointH = new(pointH_WKT, 4326, false);
SharpGeography pointV = new(pointV_WKT, 4326, false);
// Get the shortest line from the left point to the square (the point will fall in the middle of the vertical side of the square)
SharpGeography? shortestLineH = pointH.GetShortestLineTo(square);
string? shortestLineH_WKT = shortestLineH?.ToWKT();
/// Get the shortest line from the top point to the square (this time, the horizontal side of the square is not a straight line)
SharpGeography? shortestLineV = pointV.GetShortestLineTo(square);
string? shortestLineV_WKT = shortestLineV?.ToWKT();
// Create a geodesic buffer
string testWKT = "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))";
SharpGeography test = new(testWKT, 4326, false);
var buffer = test.Buffer(500000).ToWKT(8);
SqlGeography in .NET Core appsI develop and maintain SharpSpatial in my free time, focusing on practical tools I use myself in the real world.
If you find this project useful, please consider sponsoring me on GitHub.
Even a small donation helps me keep the library maintained, improved, and open for everyone.
Have an idea or feedback? Open an issue or start a discussion.
Licensed under the MIT License – free to use, modify, and distribute.
SharpSpatial uses the following third-party libraries:
These libraries retain their respective licenses.
Accurate geospatial logic for .NET, without the overhead.