[geos-devel] geos offset curve builder question

Daniel Azuma dazuma at alumni.caltech.edu
Mon Jan 31 13:04:02 EST 2011


Steve,

I suspect your issue is one of coordinate systems. GEOS works on a "flat" Cartesian coordinate system. If you were to plot those coordinates on a flat X-Y plane, I think you'll find that the offsets are as you expect. In other words, your polygon IS being offset correctly 0.0003 DEGREES both in the N-S and E-W directions. (At least, as far as I can tell by a quick glance at the KML.)

However, the earth is not flat. As a result, at 46 degrees latitude where your polygon is, each degree of latitude represents a longer distance in real life units (say, meters) than does each degree of longitude. Hence, an offset of 0.0003 degrees latitude is a greater real-life offset than 0.0003 degrees longitude, even though they're the same number of "degrees". That's what you're seeing.

GEOS does not take this into account. It does not know that your coordinates are actually longitude and latitude, and it does not try to correct for the fact that your coordinate system is not flat.

One way to correct this is first to transform your coordinates into a projection where east-west units are roughly the same as north-south units (say, a Mercator projection). Do your buffer offset in the projection, and then unproject back into lat-long space. Mercator is an easy projection to compute, and it should work pretty well if you're not too close to the poles and the sizes of your objects aren't too large compared to the size of the earth. Your example is well within these tolerances. If you want to handle objects near or covering a pole, or handle very large objects, you may have to use non-Euclidean geometry to compute an accurate buffer, and in that case, GEOS, unfortunately, won't help you.

Hope this helps,

Daniel


On 31 Jan, 2011, at 08:54, Steve Monday wrote:

> 
> All,
> 
> Given the following coordinates, I'm attempting to generate an geometry offset by a given distance.
> 
> Coordinates:
> 
> -95.00401669688529,46.00186834142991,0 -95.00107846495065,46.00180429960306,0 -95.00103515172066,46.00461557617567,0 -95.00407243675345,46.00464859106228,0 -95.00401669688529,46.00186834142991,0
> 
> Distance: 0.0003
> 
> The resulting geometry is indeed an offset from the original but not exactly what I expected.  The offset geometry seems to be offset by a greater distance on the "north/south" segments than the "east/west" segments.  I was expecting the offset geometry to be offset the same distance around the entire perimeter of the source. 
> 
> My goal is to create code that given a geometry and a distance can produce an inner offset geometry equidistant around the entire perimeter of the original.
> 
> Attached is a kml file containing the target geometry and the resulting inner offset produced by the attached code.
> 
> Thanks
> Steve
> 
> 
> 
> 
> On Mon, Jan 31, 2011 at 10:26 AM, strk <strk at keybit.net> wrote:
> On Mon, Jan 31, 2011 at 09:48:07AM -0600, Steve Monday wrote:
> > All,
> >
> > I've been using geos successfully for many months.  I appreciate the work
> > that has been invested in geos and the robustness of the api.
> >
> > I do have a "how to" question around the OffsetCurveBuilder but don't want
> > to clutter this list if geos-devel is not intended to be a general purpose
> > geos question/support mechanism.
> >
> > Am I in the right place?
> 
> Yes, being the only GEOS mailing list.
> 
> --strk;
> 
>  ()   Free GIS & Flash consultant/developer
>  /\   http://strk.keybit.net/services.html
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geos-devel
> 
> <example-offset.cpp><square_offset.kml>_______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geos-devel



More information about the geos-devel mailing list