Skip to main content
net10.0net8.0

GeoJsonCircleToPolygon is a library to convert circles to polygons and to generate GeoJSON representations of them, a fork of https://github.com/gabzim/circle-to-polygon ported to C#.

Published
Aug 12, 2026
2mo ago
Total Downloads
2.0K
1,956

Install

dotnet add package HaemmerElectronics.SeppPenner.GeoJsonCircleToPolygon --version 1.0.7
ProductVersions
.NET
net10.0net8.0

README

GeoJsonCircleToPolygon

GeoJsonCircleToPolygon is a library to convert circles to polygons and to generate GeoJSON representations of them, a fork of https://github.com/gabzim/circle-to-polygon ported to C#. Special thanks to Gabriel Zimmermann, Johannes Jarbratt and Jan ŽÔk for the original work.

Build status GitHub issues GitHub forks GitHub stars License: MIT Nuget NuGet Downloads Known Vulnerabilities Gitter Blogger Patreon PayPal

Available for

  • Net 8.0
  • Net 10.0

Net Core and Net Framework latest and LTS versions

Basic usage

public void Test()
{
    // For decimals:
    var coordinatesDecimal = new decimal[] { 173.283966m, -41.270634m };
    var resultDecimal = CircleToPolygonHelperDecimal.GetPolygonFromCircle(coordinatesDecimal, 200000, 32);
    // For usage in the GeoJSON format.
    var featureCollectionDecimal = new GeoJsonFeatureCollectionDecimal();
    featureCollectionDecimal.AddCoordinates(resultDecimal);
    var geoJsonDecimal = featureCollectionDecimal.ToString();
    // -----------------------------------------------------------
    // For doubles:
    var coordinatesDouble = new double[] { 173.283966, -41.270634 };
    var resultDouble = CircleToPolygonHelperDouble.GetPolygonFromCircle(coordinatesDouble, 200000, 32);
    // For usage in the GeoJSON format.
    var featureCollectionDouble = new GeoJsonFeatureCollectionDouble();
    featureCollectionDouble.AddCoordinates(resultDouble);
    var geoJsonDouble = featureCollectionDouble.ToString();
}

Parameters

  • center: The center coordinates: Array of length 2 (Required)
    • First element: Longitude (Required)
    • Second element: Latitude (Required)
  • radiusInMeters: Radius in meters (Required)
  • numberOfEdges: The number of edges (Defaults to 32)
  • bearing: How many degrees the circle should be rotated which is most noticeable for "circles" with few edges (Defaults to 0)
  • direction: The direction of the circle (1 means right-hand-rule, -1 is opposite) (Defaults to 1)
  • earthRadius: The earth radius (Defaults to 6378137)

Disclaimers

  • A circle whose edge cross longitude edges (-180 or 180) or a latitude edge (-90 or 90) will contain coordinate points that are outside the standardized coordinates (eg: [182, 23]). This is because there are two ways to represent a line going from [179, x] to [181, y]. One way is simply writing it as [[179, x], [182, y]] while the other is to write it as a multi-polygon. There is a plan to support multi-polygons but it has not yet been implemented.

NuGet

The project can be found on nuget.

Install

dotnet add package HaemmerElectronics.SeppPenner.GeoJsonCircleToPolygon

Change history

See the Changelog.

Changes from Previous Version

No structural changes between v1.0.6 and v1.0.7.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.