Buffering WGS84 geometry

813 views
Skip to first unread message

João Ribeiro

unread,
Mar 28, 2012, 10:18:36 AM3/28/12
to nettopol...@googlegroups.com
In response of issue109, how can i use DotSpatial to convert my Wgs84 geometry to a cartesian coordenate system?

DotSpatial.Projections.GeometryTransform.TransformGeometry(new SharpMap.Geometries.Point(referenceGeoPosition.Longitude, referenceGeoPosition.Latitude),
                  DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984,
                  DotSpatial.Projections.KnownCoordinateSystems.Projected.World.WebMercator);

Does webMercator a cartesian coordenate system? I still have distance errors.

Thanks

João Ribeiro

unread,
Mar 28, 2012, 10:33:58 AM3/28/12
to nettopol...@googlegroups.com
It is impossible i'm right? DotSpatial Buffer also uses Minkowski sum to calculate Buffer.

How can i buffer a WGS84 Geometry?

FObermaier

unread,
Mar 28, 2012, 3:58:34 PM3/28/12
to nettopol...@googlegroups.com
WebMercator is metric, but very inaccurate.
You should get better results if you take an UTM coordinate system that fits the location of the point you want to buffer.
(http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system). These should be predefined in DotSpatial.Projections.

If you buffer the transformed geometry and transform that back to wgs84 it is as good as it can get. It depends of course on the projection you choose.

Steve

unread,
May 17, 2012, 4:57:09 PM5/17/12
to NetTopologySuite
Hi

I have polygons defined with WSG84 and I need to determine if they
cross 180 longitude. We currently use in house developed code for our
geodetic calculations but this method has a bug and we would like to
use this as our first step to using open source libraries like NTS &
DotSpatial.

As I understand it I need to project my coordinates into a TBD
coordinate system then use NTS to check for intersection. I have
pasted a snippet below that attempts to create a linestring
representing the dateline. This code errors on the call to
ReprojectPoints. I have tried backing off the lat to 70 or 80 with no
success. I have tried a variety of projections, some of them don't
cause the error but I still have no confidence that they are correct.

Can someone please nudge me in the right direction?


private Coordinate reprojectCoordinate(double lon, double lat,
double vert)
{
double[] xy = new double[2];
xy[0] = lat;
xy[1] = lon;
double[] z = new double[1];
z[0] = vert;

ProjectionInfo pStart =
KnownCoordinateSystems.Geographic.World.WGS1984;
ProjectionInfo pEnd =
KnownCoordinateSystems.Projected.World.PlateCarreeworld;
Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1);

return new Coordinate(xy[0], xy[1]);
}


[TestMethod]
public void DotSpatialTesting()
{
Coordinate datelineStart = reprojectCoordinate(-90.0,
180.0, 0.0);
Coordinate datelineStop = reprojectCoordinate(90, 180.0,
0.0);

Coordinate[] datelineCoords = new Coordinate[]
{datelineStart, datelineStop};

GeometryFactory geof = new GeometryFactory();

ILineString dateLine1 =
geof.CreateLineString(datelineCoords);
}

Steve

unread,
May 17, 2012, 5:08:21 PM5/17/12
to NetTopologySuite
The coordinates in the code should look like this. I tried flipping
them just in case the order wasn't what I expected.


Coordinate datelineStart = reprojectCoordinate(180.0,
-90.0, 0.0);
Coordinate datelineStop = reprojectCoordinate(180.0, 90.0,
0.0);

Felix Obermaier

unread,
May 21, 2012, 3:17:49 AM5/21/12
to nettopol...@googlegroups.com
If the error you are getting is in the reprojection code, I suppose the DotSpatial folks will more likely be able to help you.
IIRC, the plate carree projection is nothing else than WGS84 Lat/lon treated as x/y.
IMHO all you need to do to test if your geometries are crossing the dateline is to test if the (x-values % 360) contain both values in the range e.g. 0-10 and 350-360

Hth FObermaier

> -----Ursprüngliche Nachricht-----
> Von: nettopol...@googlegroups.com
> [mailto:nettopol...@googlegroups.com] Im Auftrag von Steve
> Gesendet: Donnerstag, 17. Mai 2012 23:08
> An: NetTopologySuite
> Betreff: Re: Buffering WGS84 geometry
> --
> You received this message because you are subscribed to the Google Groups
> "NetTopologySuite" group.
> To post to this group, send email to nettopol...@googlegroups.com.
> To unsubscribe from this group, send email to
> nettopologysui...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nettopologysuite?hl=en.

Reply all
Reply to author
Forward
0 new messages