This is due to an arithmetic robustness issue in the computation of the
centroid location. The polygon centroid algorithm implemented in JTS
involves a division by the area of the polygons. In this case the area is
very, very small, and hence leads to the classic loss-of-precision problem
when dividing by small numbers in finite-precision floating point. The
loss of precision is so great in this case that the computed point lies far
away from the true value.
There's probably a clever way to rewrite the calculation to avoid the loss
of precision issue, but I don't know of a way to do this at this point.
Ideas are welcome.
I note that computing the centroid of the individual polygons produces an
accurate result. The problem is having several very small polygons spread
over a large area. There might be a way to compute a weighted average of
the individual centroids, which would probably produce a better result.
On Thu, Oct 31, 2013 at 10:54 AM, Daniel Baston <[email protected]>wrote:
> Hello,****
>
> ** **
>
> JTS 1.13 is reporting what seems to be a curious result when computing the
> centroid of this tiny geometry:****
>
> ** **
>
> MULTIPOLYGON (((-92.661322 36.58994900000003, -92.66132199999993
> 36.58994900000005, -92.66132199999993 36.589949000000004, -92.661322
> 36.589949, -92.661322 36.58994900000003)), ((-92.65560500000008
> 36.58708800000005, -92.65560499999992 36.58708800000005, -92.65560499998745
> 36.587087999992576, -92.655605 36.587088, -92.65560500000008
> 36.58708800000005)), ((-92.65512450000065 36.586800000000466,
> -92.65512449999994 36.58680000000004, -92.65512449998666 36.5867999999905,
> -92.65512450000065 36.586800000000466)))****
>
> ** **
>
> The centroid result I receive in code and in JTS TestBuilder is as follows:
> ****
>
> ** **
>
> POINT (-287.27272727272725 153.3090909090909)****
>
> ** **
>
> Any thoughts on what might be causing this?****
>
>
> Thanks,****
>
> Dan****
>
>
> ------------------------------------------------------------------------------
> Android is increasing in popularity, but the open development platform that
> developers love is also attractive to malware creators. Download this white
> paper to learn more about secure code signing practices that can help keep
> Android apps secure.
> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
> _______________________________________________
> Jts-topo-suite-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>
>
------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Jts-topo-suite-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user