[gdal-dev] Simple circle in OGR

Mike Toews mwtoews at gmail.com
Wed Nov 2 16:33:57 PDT 2016


On 3 November 2016 at 09:46, Renison <rex200789 at gmail.com> wrote:
> Hello all, I am trying to create a simple circle geometry in OGR. My approach
> so far has been something like this:
>
>             SpatialReference defaultGeoSys = new SpatialReference("");
>             defaultGeoSys.SetWellKnownGeogCS("EPSG:4326");
>
>             //define a circle using point and buffer
>             string pointlineString = "POINT (" + longitude + " " + latitude
> +")";
>             var circle = OGR.Ogr.CreateGeometryFromWkt(ref pointlineString,
> defaultGeoSys);
>             circle.Buffer(MilesToMeters(radiusInMiles), 2000);
>
> But the circle.Buffer(params,params) does not seem to create a circle. All I
> have is a point and a radius. Is there a way to achieve what I want?

Buffer operates in Cartesian space, and uses the same units as the
SRS, therefore these are degrees.

One strategy for a simple Point is to create a Cartesian buffer from
(0, 0) and project it to EPSG:2193 from a custom azimuthal equidistant
projection centred at the point location, e.g. a PROJ.4 string
"+proj=aeqd +lat_0=" + latitude + " +lon_0=" + longitude + " +x_0=0
+y_0=0"

See http://gis.stackexchange.com/a/121539/1872 for this recipe in R.
You can make something similar with OSR.

Cheers,
-Mike


More information about the gdal-dev mailing list