Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a .NET library to calculate area enclosed by polygon made up of geo coordinates (lat longs)?

share|improve this question
up vote 5 down vote accepted

SharpMap has a polygon class with an Area method. But before calling that, you should consider projecting the polygon's coordinates into an equal area projection to yield meaningful results. It looks like SharpMap uses ProjNet, which has Albers, but I also see there is now a c# wrapper for Proj4.

share|improve this answer

NetTopologySuite offer what you need, and much more:

share|improve this answer
+1 I'd forgotten about nettopologysuite, looks like it has a lot more momentum than SharpMap. – Kirk Kuykendall Oct 2 '11 at 21:06

Another option is using the Microsoft.SqlServer.Types library. While it isn't supplied in .NET, it is available as a nuget package, or you can find it in your SqlServer (or Express) installation (%programfiles%\Microsoft SQL Server\100\SDK\Assemblies) as Microsoft.SqlServer.Types.dll

Obviously, it relies on Microsoft (and the SQL types library which could have it's own licencing issues), so the other options supplied may well be better options, but if you are already integrating with SqlServer 2008, then this may be a nice way to go.

To do an area calculation is pretty simple (I have included an NUnit test below demonstrating it.

using System;
using System.Text;
using Microsoft.SqlServer.Types;
using System.Data.SqlTypes;
using NUnit.Framework;

namespace YourNamespace
    class GeometryTest

        public void CheckAreaTest()
            string polygon = "POLYGON((145 -42 , 147 -42, 147 -40, 145 -40, 145 -42))"; //wkt string over Tasmania, Australia
            SqlGeography geom = new SqlGeography();
            SqlChars geometryString = new SqlChars(new SqlString(polygon));
            geom = SqlGeography.STPolyFromText(geometryString, 4326);
            Assert.AreEqual(37371149986.1, Math.Round(geom.STArea().Value, 1));


share|improve this answer
While your example helps achieve find the area but it doesn't address the part where I said that I have lat, longs because area needs to be calculated in meters. – Hasan Khan Oct 3 '11 at 2:55
By using SqlGeography, the STArea is automatically in square metres (which is why it is so big). Will ammend to give better values in the string polygon string to avoid confusion. – Kelso Oct 3 '11 at 3:17

Link to System.Data.Entity.dll and use the DbGeography object such as:

DbGeography geography = DbGeography.FromText(wktString);
double? myArea = geography.Area;
share|improve this answer
Welcome! Expanding on your answer may be helpful for the original poster and any future people who find this post in the future. – MaryBeth Dec 18 '15 at 13:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.