Using the centroid of the convex hull would certainly avoid the current
issue where the computed centroid lies very far from the input geometries.
And it would probably satisfy a major use case (the only one?), which is
to provide a point "in the middle" of the geometry.
However, since it does not take area into account it would not reflect the
"mass distribution" of the polygons in the same way that centroid does.
For example, consider a set of 1000 polygons where 999 are clustered
together and one lies very far away. The true centroid would lie almost in
the middle of the cluster, whereas the hull-based one would lie halfway
between the outlier and the cluster.
I'm pretty sure that using a area-based weighted average of the individual
centroids (which can be computed more robustly) will produce a good answer.
On Sat, Nov 2, 2013 at 2:42 AM, Imran Rajjad <[email protected]> wrote:
> Hello,
>
> Can't you create a convex hull for all tiny polygons in single geometry
> and take centroid of convex hull polygon?
> Regards,
> Imran
> On Nov 1, 2013 9:20 PM, "Martin Davis" <[email protected]> wrote:
>
>> 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
>>
>>
------------------------------------------------------------------------------
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