DotSpatial Library : MapWindow Discussion Forum
Hello, 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 G
How to buffer in Lat Long
Posted by: mailvamsee ()
Date: June 24, 2010 10:41AM

Hello,

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.

Thanks,

VK.

Options: ReplyQuote
Re: How to buffer in Lat Long
Posted by: mailvamsee ()
Date: June 24, 2010 11:19AM

Ok I am almost there, but not quite.

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.

Thanks,

VK

Options: ReplyQuote
Re: How to buffer in Lat Long
Posted by: Shade1974 ()
Date: June 24, 2010 11:46AM

This will work fine in most cases in the vertical direction, but is going to be a bit off in the horizontal direction. There are two options available to you.

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.

Shade1974 (Ted)
Dr. Harold A Dunsford Jr.
MapWindow 6.0 & DotSpatial Initial Developer
GEI Consultants

Options: ReplyQuote
Re: How to buffer in Lat Long
Posted by: mailvamsee ()
Date: June 28, 2010 04:48PM

Dr. Dunsford,

Thank you for the detailed explanation. I'll try your second suggestion.

VK.

Options: ReplyQuote


Sorry, you do not have permission to post/reply in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: