0

I'm trying to learn how to use NetTopologySuite (for .NET) but creating a simple circle which is going to be my search area. When I do this using the .Buffer() method, the shape created covers the entire planet Earth.

var geographyFactory = NtsGeometryServices.Instance.CreateGeometryFactory(4326); // WGS84

var searchAreCoordinate = new NetTopologySuite.Geometries.Coordinate(coordinate.Latitude, coordinate.Longitude); // Not sure if long-lat or lat-long.

var searchArea = geographyFactory.CreatePoint(searchAreCoordinate).Buffer(1000); // To me, this is 1000 meters because the SRID is WGS84.

This is the result WKT output:

POLYGON ((1001 2, 981.78528040323044 -193.09032201612825, 924.8795325112867 -380.6834323650898, 832.46961230254522 -553.57023301960214, 708.10678118654755 -705.10678118654755, 556.57023301960226 -829.46961230254522, 383.68343236508986 -921.8795325112867, 196.09032201612834 -978.78528040323044, 1.0000000000000613 -998, -194.0903220161282 -978.78528040323044, -381.68343236508974 -921.8795325112867, -554.57023301960191 -829.46961230254533, -706.10678118654744 -705.10678118654755, -830.46961230254533 -553.57023301960214, -922.87953251128681 -380.68343236508946, -979.78528040323056 -193.09032201612771, -999 2.0000000000007656, -979.78528040323022 197.09032201612922, -922.87953251128624 384.68343236509088, -830.46961230254442 557.57023301960339, -706.1067811865463 709.10678118654869, -554.57023301960078 833.46961230254624, -381.68343236508787 925.87953251128749, -194.09032201612607 982.7852804032309, 1.0000000000024809 1002, 196.09032201613093 982.78528040322988, 383.68343236509247 925.87953251128567, 556.57023301960487 833.46961230254351, 708.10678118654994 709.10678118654516, 832.46961230254726 557.5702330195993, 924.87953251128818 384.68343236508628, 981.78528040323124 197.09032201612436, 1001 2))

and this is what it looks like, when placed over a map:

enter image description here

If you look at the result data, the numbers are way over -90/90 -180/180.

My guess is that I might not be setting the SRID right?

halfer
  • 19,824
  • 17
  • 99
  • 186
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647

1 Answers1

-1

Your map and data are measured in degrees (because you have set the projection to EPSG:4326) thus you have asked for a buffer 1000 degrees in size and as there are only 360 degrees around a sphere you get a circle containing the whole earth.

If you want to work in metres/feet you need to reproject your map and data points to a projected coordinate system. However, please don't pick EPSG:3857 as that is really distorted once you leave the equator and completely unsuitable for buffering too.

Ian Turton
  • 10,018
  • 1
  • 28
  • 47
  • 2
    Wait, really? I'm used to using the Sql Server Spatial extensions with `STBuffer`, etc. I swear i did spatial stuff with co-ords and using 4326 SRID. So why is this so different? Are there docs/tutorials on this because there so little documentation out there :( – Pure.Krome May 24 '20 at 23:20