2

I am using JTS to compute intersections between polygons with WGS84 lat/lon coordinates. I am not converting coordinates to anything 2D based, just reading in POLYGON(lat lon, lat lon) and doing geometry1.relate(geometry2).

Will that give me correct answers all the time?

My polygons are roughly 1m to 100m in size, located in US and Alaska.

If it's completely wrong, should I convert WGS84 to UTM? Using JTS/GeoTools/Proj4J ?

5
  • 1
    Welcome! Please take the tour: gis.stackexchange.com/tour and update your question to include what you have already tried and what you are having problems with. – MaryBeth Dec 28 '15 at 15:19
  • Coordinates are usually in X,Y order, so your constructor should be "lon lat, lon lat,..." One meter is an awfully small area for a GCS geometry. – Vince Dec 28 '15 at 15:28
  • @Vince you are correct. (lon,lat) sorry about that. 1m dimensions has to do with GPS coordinates (which are very accurate) and outlines of buildings. My JTS usage will be to see if person's gps location is inside a building, bounding box, or "hull" of the building. – Elijah Dec 28 '15 at 15:42
  • I think you need to explain what you mean by "correct." – Rob Skelly Dec 28 '15 at 22:59
  • By "correct" I mean that intersection of two geometries will be correctly identified by JTS library despite me using lon/lats. So far it seems that my test cases pass. But i cant tell if i'm lucky with test cases. – Elijah Dec 28 '15 at 23:11
4

JTS will just treat the lat/longs as Cartesian coordinates so as long as they don't cross the date line, the results will be as correct as the underlying implementation. If you're worried about the dateline, you can supply a translation to guarantee that never happens.

However, depending on the projection you ultimately use and the shape of your geometries, you could get output that's incorrect in other ways:

enter image description here enter image description here

The first image is projected using Alaska Albers, the second is Lat/Lon. Both images have two triangles. One triangle has 3 vertices so the sides are always rendered as straight lines. The other has 103 vertices, so the projected sides appear to curve. In lat/lon, they appear identical.

Of course, this phenomenon has nothing to do with JTS, which is projection-agnostic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.