Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the distance units in com.vividsolutions.jts.geom.Geometry class?

Our VB.NET project is using a Java library from Vivid Solutoins (com.vividsolutions.jts.geom.Geometry) to do Geometry calculations. The help is here: http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html

What I can't figure out are the units specifically for the Buffer property, or any other distance for that matter. My program is dealing with Nautical Miles, and the documentation gives no indication if the units are degrees, miles, Nautical Miles, Kilometers, inches, etc.

Has anyone used this library who knows the answer? Thanks in advance.

like image 709
Andy Jacobs Avatar asked Jan 28 '10 14:01

Andy Jacobs


4 Answers

As I recently worked on this library (http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html) and after investigation I found that the unit distance returned when call some of the methods distance calculation with this api will be in degree unit. To convert it to kilometer, assumes that value returned is d then you need to convert it to radian and multiply with earth radius 6371km. The formula would be d / 180 * PI * 6371.

like image 105
Duong Avatar answered Nov 18 '22 02:11

Duong


I confirmed with one of the author's of the library, and by testing it myself using geospatial files with different projections, that the distance units depend on the source file's CRS. This is covered in their FAQ here: https://locationtech.github.io/jts/jts-faq.html#B5

A quick way to find this is to look up the EPSG code at http://epsg.io/ and find the units. For example, EPSG 3347 has units of metres.

like image 37
Brideau Avatar answered Nov 18 '22 04:11

Brideau


First of all, I don't know this API, I've just browsed the link you've given.

Judging by the Javadocs for Coordinate, it says:

[Coordinate is a] lightweight class used to store coordinates on the 2-dimensional Cartesian plane. It is distinct from Point, which is a subclass of Geometry. Unlike objects of type Point (which contain additional information such as an envelope, a precision model, and spatial reference system information)

So it would seem that Geometry has no units as such, but Point, its subclass, does, and you can specify them.

I wouldn't be surprised if the Geometry class doesn't have any units as such, and just represents the concept of a point in space in any particular coordinate system.

like image 21
Rich Avatar answered Nov 18 '22 02:11

Rich


This is an old post, but here is the answer for anyone else who is looking, since incredibly the java docs do not state the units returned by the method. The distance returned is in central angle degrees. You can then use any number of formulas to convert to your required unit of measure. The simplest is to convert to radians. 1 radian = 180 degrees divided by pi (rad=180deg/pi). From there, you can multiply radians by the average radius of the earth in your choice of units (6371 km for instance) to get distance between two points. More accurate methods are also available, but you can look them up on the net.

like image 5
Tim Green Avatar answered Nov 18 '22 02:11

Tim Green