DbGeography make circle with center and radius

不羁岁月 提交于 2019-12-03 20:34:49
Eric Conway

Create a DbGeography Circle by creating a PointFromText and then Buffer that point by the radius. For the WGS84 coordinate system the DbGeography radius units appear to be in kilometers.

string textPoint = String.Format("POINT ({0} {1})", longitude, latitude);
DbGeography point = DbGeography.PointFromText(textPoint, DbGeography.DefaultCoordinateSystemId); //4326 = [WGS84]
DbGeography targetCircle = point.Buffer(radiusKilometers);

Edited with info from adrian about DbGeography.DefaultCoordinateSystemId.

Look at Buffer method: http://msdn.microsoft.com/en-us/library/hh506085(v=vs.110).aspx

It creates a circular buffer around a point. It can be used on other types of geometries/geographies as well.

Be careful if the radius is quite big when using for geography (few kilometers should be OK)

I am not sure how it is implemented in C# but I would definetely use that in other spatial tools.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!