<https://stackoverflow.com/posts/60358771/timeline>

I have a large Polygon and large LineString, enough to account the
curvature of the earth and i wanted to calculate the intersecting distance
between the two.I have tried using the auto projection but still i can't
get close results. I already went through Ian's blog
<https://blog.ianturton.com/geotools,/projections/2017/08/01/area-of-a-polygon.html>
to
calculate area of polygon where it is clearly mentioned that it is only for
small polygons as JTS does'nt take the curvature of the earth into
consideration where the GeodeticCalculator does. Should i find the first
and the last intersecting point and may be then use the GeodeticCalculator
to calculate the intersecting distance or there is any other way to do
this, may be like equal area projection? Below is my code

  DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
    GeometryFactory geomFactory = new GeometryFactory();

    //my WGS 84 crs axis order is longitude first hence all
coordinates are long,lat
    Coordinate[] polygonCoOrdinates = new Coordinate[]{new
Coordinate(44.783323, -13.115134),
            new Coordinate(43.381886, -10.994365),
            new Coordinate(45.367769, -4.368934),
            new Coordinate(51.220897, 4.818909),
            new Coordinate(59.268949, 16.105438),
            new Coordinate(67.52604, 10.616453),
            new Coordinate(69.825484, 4.402182),
            new Coordinate(73.274649, -0.923968),
            new Coordinate(65.749198, -10.789091),
            new Coordinate(52.579659, -10.686401),
            new Coordinate(44.783323, -13.115134)
    };

    Coordinate[] lineStringCoordinates = new Coordinate[]{new
Coordinate(72.8777, 19.0760),
            new Coordinate(31.049999, -29.883333)
    };

    LineString lineString = geomFactory.createLineString(lineStringCoordinates);

    LinearRing ring = geomFactory.createLinearRing(polygonCoOrdinates);

    org.locationtech.jts.geom.Polygon polygon =
geomFactory.createPolygon(polygonCoOrdinates);

    Geometry geometryIntersection = polygon.intersection(lineString);
    Point centroid = polygon.getCentroid();
    String code = "AUTO:42001," + centroid.getX() + "," + centroid.getY();
    CoordinateReferenceSystem auto = CRS.decode(code);

    MathTransform transform =
CRS.findMathTransform(DefaultGeographicCRS.WGS84, auto);
    Geometry projgeometryIntersection =
JTS.transform(geometryIntersection, transform);
    double areaa = projgeometryIntersection.getArea();


*Regards,*
*Nikhil Karanjkar*
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to