I think I found this by searching for circum in findFn from sos package
On Friday, May 17, 2013, Mathieu Rajerison wrote:
> Thanks Michael for the answer.
>
> How come that I didn't find this solution on google?...When you use rseek
> and type circumscribing circle, you don't find any mention t
Thanks Michael for the answer.
How come that I didn't find this solution on google?...When you use rseek
and type circumscribing circle, you don't find any mention to the tripack
package..Maybe it's because the fnction has been developed lately? the
latest version of tripack being from february 20
Just FYI, there is tripack::circumcircle, here's an example with data
in the maptools package.
library(maptools)
data(wrld_simpl)
poly <- wrld_simpl[wrld_simpl$NAME == "Australia", ]
## use coercion to get raw vertices (long winded, but avoids @ usage)
coords <- coordinates(as(as(poly, "Spatia
Hey Mathieu and Greg,
Great ideas, and thanks for the code Mathieu.
I can't imagine a polygon shape where the 2nd step would ever by necessary?
Can you elaborate on why that might be.
FYI, Mathieu I'm attempting to compute the same shape/linearity metric as
you.
Cheers,
Jed
-
Jed Long
Hello,
Here is a code based on Greg's second idea (1st step: find the furthest
points of the polygon, 2nd step: find the circumscribed circle of a
triangle)
I wrote a function that computes the smallest circumscribing circle of a
triangle, and one that searches for the furthest vertices of a pol
The "dists" variable represents the distance between the points and the
circle measured along the radius of the circle. Positive distances mean
that the point/vertex is inside the circle and negative distances mean that
the point is outside of the circle. Without some type of penalty the
optimal
Thinking through this a little more I think I have a better algorithm to
start with:
Find the 2 vertices that are farthest from each other (the dist function
will compute all pairwise distances). If you have highly concave polygons
or lots of vertices then using the chull (convex hull) may speed
Thanks a lot for your answer.
I wasn't familiar with optimization methods.
One question I asked myself was how to determine the optimal center
coordinates and radius to start the optimization with.
So, based on your code:
- I used the centroid as the center
- half the size of the biggest side of
Here is one possibility to get you close:
vert.x <- c(0,0,1,1)
vert.y <- c(0,1,1,0)
myfun <- function(theta) {
x <- theta[1]
y <- theta[2]
r <- theta[3]
dists <- r - sqrt( (vert.x-x)^2 + (vert.y-y)^2 )
sum( dists^2 ) + 10*sum(dists<0)
}
out <- optim( c(0,0,5), myfun )
out
plot( -1:2, -1:2, ty
I made a little mistake. The formula is 1 - area(shape) / area(circum),
not 1 - area(circum) / area(shape)
2013/1/24 Mathieu Rajerison
> Hi,
>
>
> I know spatstat::incircle to calculate the inscribed circle of a shape.
>
> I'd like to know if there was a function to calculate the circumscribing
Hi,
I know spatstat::incircle to calculate the inscribed circle of a shape.
I'd like to know if there was a function to calculate the circumscribing
circle of a polygon.
The area of this circumscribing circle could then be used to calculate a
linearity index: 1 - area(circum) / area(shape)
For
11 matches
Mail list logo