[R-sig-Geo] Find a circle center with spatial points

Chris Reudenbach reudenbach at uni-marburg.de
Fri Mar 18 23:28:51 CET 2016


Oops :-[ , Barry thanks for clarification , I got it now.

I don't understand the math either but as a kind of "reparation"
for not reading well enough I found the authors java code.
https://www.spaceroots.org/documents/circle/CircleFitter.java
After download you should for standalone compilation delete line 37 
"package org.spaceroots;"
compile it with:

  javac CircleFitter.java -Xlint:unchecked

then you can run it with:

java CircleFitter input.file

The input data should be formated like:

# input
# x y
0 5
1 4.5
2.5 4
3 3.5
4 2
5 0

the above input yields

initial circle: -001.69467803 -000.69446643 006.23578103
converged after 7 iterations
final circle: -001.34339845 -001.34426151 006.44308386
with the format x,y,radius

which at least make sense with respect to the data.

You easily can  run it from R by system() and grab the output in a file 
using a OS depending pipe
or you may run it using the rJava package which could be more complex.

cheers Chris

if you want you can call it from R with javaR

Am 18.03.2016 um 20:11 schrieb Barry Rowlingson:
> On Fri, Mar 18, 2016 at 6:49 PM, Chris Reudenbach
> <reudenbach at uni-marburg.de> wrote:
>> Because it seems to be an arc and not a circle issue that you can solve the
>> problem by
>> picking arbitrary two points of your assumed "arc" then construct
>> (calculate)  the perpendicular bisector of
>> the line between them and do so for another arbitrary two points of the
>> assumed "arc".
>>
>> The intersection of the perpendicular lines is the assumed center of the
>> arc.
>>
>> If you iterate over all points this should be a pretty good estimation of
>> the real center.
>   This is the  "sample 3 points and find the fitted circle" idea, you
> are likely to get massive "outliers" and if you take the mean
> coordinate it could fail horribly. See the paper I linked to for an
> example. They use the median to get an initial "robust" estimate of
> x,y,R, and then use some specialised optimisation to improve the
> estimate - you can't just throw it into "optim"!
>
>   Not sure I understand the maths in it yet though....
>
> Barry
>



More information about the R-sig-Geo mailing list