Meziantou.Framework.Geo 1.0.2

Prefix Reserved
dotnet add package Meziantou.Framework.Geo --version 1.0.2
                    
NuGet\Install-Package Meziantou.Framework.Geo -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Meziantou.Framework.Geo" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.Framework.Geo" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Meziantou.Framework.Geo" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Meziantou.Framework.Geo --version 1.0.2
                    
#r "nuget: Meziantou.Framework.Geo, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Meziantou.Framework.Geo@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Meziantou.Framework.Geo&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Meziantou.Framework.Geo&version=1.0.2
                    
Install as a Cake Tool

Meziantou.Framework.Geo

Reads and writes maps in GeoJSON, TopoJSON, Shapefile, KML, KMZ, GPX, WKT, WKB, encoded polylines and FlatGeobuf, with features, geometries, geometry operations (repair, clip, simplify, union, intersection, difference, distance, buffer, convex hull) and map projections. No dependency outside .NET.

Usage

The types are in the Meziantou.Framework.Geo namespace. Every format is a static class with Read/Parse and Write/Format methods, which return and take a GeoFeatureCollection.

GeoFeatureCollection countries;
using (var stream = File.OpenRead("countries.geojson"))
{
    countries = GeoJson.Read(stream);
}

// A JSON number is a double, and a string is a string
var large = countries.Where(country => (double)country.Properties["population"]! > 50).ToList();
Assert.Equal("France", Assert.Single(large).Properties["name"]);

using (var stream = File.Create("large-countries.geojson"))
{
    GeoJson.Write(new GeoFeatureCollection(large), stream, new GeoJsonWriterOptions { Indented = true });
}

Compute distances and test whether a position is inside an area:

// A square with a square hole
var polygon = new GeoPolygon(
[
    [new(0, 0), new(10, 0), new(10, 10), new(0, 10), new(0, 0)],
    [new(4, 4), new(6, 4), new(6, 6), new(4, 6), new(4, 4)],
]);

Assert.True(polygon.Contains(new GeoPosition(Longitude: 2, Latitude: 2)));
Assert.False(polygon.Contains(new GeoPosition(Longitude: 5, Latitude: 5))); // in the hole
Assert.False(polygon.Contains(new GeoPosition(Longitude: 12, Latitude: 5)));

Project positions onto a plane to draw a map:

var projection = new MercatorProjection();

// The point is in radii of the Earth, with y increasing to the north
var (x, y) = projection.Project(new GeoPosition(Longitude: 2.35, Latitude: 48.86));

// Scale and translate it to draw a map of 512 by 512 pixels, as the tiles of web maps
var pixelX = 256 + (x * 256 / Math.PI);
var pixelY = 256 - (y * 256 / Math.PI);
Assert.Equal(259.34, pixelX, 0.01);
Assert.Equal(176.14, pixelY, 0.01);

// Invert converts a point back to a position
var position = projection.Invert(x, y);
Assert.Equal(48.86, position!.Value.Latitude, 1e-9);

Formats

Format Class Read Write
GeoJSON GeoJson ✓ ✓
TopoJSON TopoJson ✓ ✓
Shapefile (.shp, .dbf, zipped) Shapefile ✓ ✓
KML / KMZ Kml, Kmz ✓ ✓
GPX Gpx ✓ ✓
WKT / WKB (and PostGIS EWKT / EWKB) WellKnownText, WellKnownBinary ✓ ✓
Encoded polyline EncodedPolyline ✓ ✓
FlatGeobuf (with its spatial index) FlatGeobuf ✓ ✓

The positions are longitudes and latitudes in degrees (WGS 84). CoordinateReferenceSystem converts data in Web Mercator, UTM, Lambert 93 and other transverse Mercator, Lambert conformal conic and Mercator projections to them, from an EPSG code (the SRID of EWKT and EWKB) or the WKT of a .prj file.

Product 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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net11.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Meziantou.Framework.Geo:

Package Downloads
Meziantou.Framework.Geo.Maps

Loads offline map bundles: the borders, states and provinces, cities, rivers, lakes, coastlines, land, ocean, seas and physical regions of a region, stored as folders of FlatGeobuf or GeoJSON layers, or in other formats such as GeoPackage.

Meziantou.Framework.Charts

Grammar-of-graphics chart library that renders deterministic SVG: bar, line, area, scatter, pie, radar, gauge, packed circles, treemap, sunburst, histogram, box plot, heatmap, waterfall, funnel, candlestick, choropleth maps and more, built from marks, scales, coordinates and transforms.

Meziantou.Framework.Geo.GeoPackage

Reads the feature tables of GeoPackage files (.gpkg), the SQLite format of GDAL, QGIS and ArcGIS, as the features of Meziantou.Framework.Geo, with a streaming reader and the R-tree spatial index to read a region.

Meziantou.Framework.Geo.GeoParquet

Reads GeoParquet files (.parquet), the columnar format of geospatial data lakes, as the features of Meziantou.Framework.Geo, one row group at a time, skipping the row groups outside of a region.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 43 11/13/2026
1.0.1 183 11/8/2026
1.0.0 2,724 11/6/2026