I am trying to create a buffer via code for a line. It works fine when the map has a projection, but if its in Lat Long WGS 84 I am having issues.
How can I convert a distance that I want to use for the buffer ex: 50 miles to a lat long unit that I can pass to Geometry.Buffer() method.
I will really appreciate any help.
I am converting the buffer distance to meters and then dividing that by 111319.5 (Degrees of latitude, and of longitude at the equator, are thus equal to 111319.5 meters.) to convert to decimal degrees.
When I measure the buffer after its created is close to what I want but its off a little. Is there a better way to do this.
The first, and recommended, option is that if distance units in linear units are important to you, reproject the coordinate system for your entire map into a local Universal Transverse Mercator or State Plane projection. These are more local in nature, meaning that you need to familiarize yourself with the UTM zone, or the name of the state plane that encapsulates your dataset. After reprojecting, the linear units of the entire map will be in meters (or feet). In such a case, the distortions have already been handled, and you can use a regular linear unit for your buffer radius.
The second option still relies on the projection library, but is a little bit sneakier. Don't bother with reprojecting your original datasets. (especially if some of those are an images or grids). Instead, just reproject the line you need to get the buffer for into one of the appropriate UTM zones. Then, calculate your polygon with a buffer radius in meters. Finally, reproject back the vertices of that polygon. The result should be a slightly distorted shape.
Both of the above options involve reprojection, which you may not be familiar with, but is supported on the FeatureSet via the Reproject method. I recommend building the coordinate systems using the System.Spatial.Projections.KnownCoordinateSystems class, which lets you select a coordinate system programmtically much the same way as you would in the projection selection dialog.
There are other options when you are talking about just one or two points, but when calculating an entire buffer, it is probably better just to use the the projection libraries to their maximal benefit.
Dr. Harold A Dunsford Jr.
MapWindow 6.0 & DotSpatial Initial Developer
Thank you for the detailed explanation. I'll try your second suggestion.