Calculating area from getArea

146 views
Skip to first unread message

Usman Anwar

unread,
Apr 6, 2016, 12:25:52 PM4/6/16
to JSTS devs
Hello,

How would I calculate the area (sq. km) from a WKT geometry?

This is the code I'm currently using, but I'm unsure of the units being returned by the getArea method.

var reader = new jsts.io.WKTReader();
reader.geometryFactory.SRID = 4326;

var wkt = "MULTIPOLYGON (((-106.12111451780238 37.64724119739066, -106.11192659001627 37.647329418896476, -106.11198712862522 37.64378221039577, -106.11204658161049 37.64029852468793, -106.1212345093966 37.64062429560224, -106.1211764726814 37.6438247584796, -106.12111451780238 37.64724119739066)))"

var multipolygon = reader.read(wkt);

multipolygon.getArea();

=> 0.00006271173401915205

If this is in degrees, what is the best way to convert this to square km?

Thanks.

Björn

unread,
Apr 6, 2016, 12:58:01 PM4/6/16
to JSTS devs
JSTS does not contain any algoritms for calculating with geographic coordinates, it assumes Cartesian coordinates.

/Björn
Reply all
Reply to author
Forward
0 new messages