Hi all,
Here is a method to calculate a centroid which lies inside a region.
Well I seem to have finished this coding.
I have shared a link to the class.
You just need to invoke the public method findMeanPosition(<the vector of
longitudes>), This will give you the mean longitude.
Calculating the mean latitude is easy, it is just a normal mean because
latitude values range from -90 to 90 so they don't bother us about caring
about crossing the 180.
At present there are a lot of print statements, which I will remove once I
am done with writing the tests for this class.
https://github.com/dapurv5/phyloGeoRef/blob/master/phyloGeoRef/src/nescent/phylogeoref/processor/utility/ComputeUtility.java
This is an O (n log n) algorithm where n is the number of points of the
polygon. Atleast theoretically it works out to be it.
--
thanks and regards,
~Apurv Verma
B. Tech.(CSE)
IIT- Ropar
Mobile - 09256587545
On Tue, Jul 26, 2011 at 7:55 AM, Michael Bedward
<[email protected]>wrote:
> If the data points span most of the globe then the definition of
> inside-ness becomes a little difficult :)
>
> A link to your algorithm posted to the list would be much appreciated.
> It could well be useful for other applications.
>
> Good luck with it.
> Michael
>
> On 26 July 2011 00:44, Apurv Verma <[email protected]> wrote:
> > Hi Mike,
> > Yes on the plane it's easy. But in spherical geometry it's not more so
> when
> > the points may span the entire globe, I have a previous algorithm but
> just
> > wanted to know if there is something ready made already.
> > Once I implement that algorithm I will post a link to it on the list here
> so
> > that people interested in calculating centroids on the surface of earth
> > might use it.
> >
> > Sure I will look at R.
> >
> > You are really doing a wonderful job, I see you handle a lot of emails
> > everyday. :P
> >
> > ~Apurv Verma
> > B. Tech.(CSE)
> > IIT- Ropar
> > Mobile - 09256587545
> >
> >
> >
> >
> >
> >
> > On Mon, Jul 25, 2011 at 6:20 PM, Michael Bedward <
> [email protected]>
> > wrote:
> >>
> >> Hi Apurv,
> >>
> >> Thanks for that - I understand better now.
> >>
> >> I guess by multidimensional scaling you mean any heuristic that would
> >> give a "good enough" solution with some indication of goodness of fit,
> >> e.g. classic MDS but also simulated annealing etc. I don't think
> >> either GeoTools, or the JTS library which it uses for geometry
> >> operations, have what you want, though I'd be happy to be corrected by
> >> someone else here.
> >>
> >> In the plane I **think** that the coordinate that minimizes the sum of
> >> distances to all points in a set is the median, ie. centroid.x =
> >> median of point.xs, centroid.y = median of point.ys. If your points
> >> are often close together (local or regional scales) you could just
> >> work with Cartesian coordinates in some convenient map projection.
> >> However, you emphasize spheroidal distance in your post so I'm
> >> guessing that your point sets cover a large area. In that case I've no
> >> idea whether there is an easy solution, but once again it depends on
> >> how critical the minimum sum of distances criterion is for your
> >> application.
> >>
> >> GeoTools does have the GeodeticCalculator class which can compute
> >> distances between points on a spheroid. So you could use that in
> >> conjunction with an optimizing algorithm from another library.
> >>
> >> As an aside, why are you searching in GeoTools for this ? I would
> >> have thought the first stop would have been R (which has many packages
> >> for spatial analysis) or similar.
> >>
> >> Sorry I can't be more directly helpful but please let us know how you
> go.
> >>
> >> Michael
> >>
> >>
> >> On 25 July 2011 19:32, Apurv Verma <[email protected]> wrote:
> >> > Hi Michael,
> >> > I am extremely sorry that I did not cc my message to the list last
> >> > time.
> >> > Thanks for providing me with the link.
> >> >
> >> > Well let me tell me you my problem in detail.
> >> > From the pdf I found that the minimum distance centroid would be the
> >> > closest
> >> > that I would want. How can I compute it. However it would be better if
> >> > something of the following is provided.
> >> > I have a set of points on the surface of earth. I want to calculate a
> >> > central point such that the distance from it to the given points is in
> >> > required proportion with the additional requirement that this point
> >> > should
> >> > be inside the polygon obtained by joining the points.
> >> > It's easy to see that a such a requirement cannot be perfectly met.
> Let
> >> > me
> >> > give you an analogy in the euclidean geometry rather than spherical
> >> > geometry.
> >> > Suppose I have 4 points in the Euclidean plane. I want to calculate a
> >> > point
> >> > which is equidistant/distances in equal proportions to the 4 points.
> Now
> >> > this is not always possible because if I choose a circle to pass
> through
> >> > 3
> >> > points, it's not necessary that the fourth point too lies on the
> circle.
> >> > (because 3 points uniquely define a circle.)
> >> > So then we can do a kind of multidimensional scaling. Such that we try
> >> > to
> >> > find a point which satisfies the criterion as best as it can.
> >> > While this is challenging enough to calculate on a euclidean plane.
> >> > Spherical geometry makes things even worse!!
> >> >
> >> > I hope I was able to explain myself. Please do ask me if I was not
> >> > clear.
> >> >
> >> > --
> >> > thanks and regards,
> >> >
> >> > ~Apurv Verma
> >> > B. Tech.(CSE)
> >> > IIT- Ropar
> >> > Mobile - 09256587545
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > On Mon, Jul 25, 2011 at 1:10 PM, Michael Bedward
> >> > <[email protected]>
> >> > wrote:
> >> >>
> >> >> Hello,
> >> >>
> >> >> Please reply via the list.
> >> >>
> >> >> So what sort of centroid do you want ? There are many in common use
> >> >> (see
> >> >> http://user.gs.rmit.edu.au/rod/files/publications/MSIA_Centroid.pdf
> >> >> for a comparison of some).
> >> >>
> >> >> Or is it enough to have any point that is inside some polygon formed
> >> >> by the data points e.g. the convex hull ?
> >> >>
> >> >> Michael
> >> >>
> >> >>
> >> >> On 25 July 2011 16:58, Apurv Verma <[email protected]> wrote:
> >> >> > Yes it is a type of centroid calculation only.
> >> >> > Given a polygon on the surface of earth, I need to calculate its
> >> >> > centroid.
> >> >> > Have a look at this page.
> >> >> > http://www.fmepedia.com/index.php/InsidePointReplacer
> >> >> >
> >> >> > thanks and regards,
> >> >> >
> >> >> > ~Apurv Verma
> >> >> > B. Tech.(CSE)
> >> >> > IIT- Ropar
> >> >> > Mobile - 09256587545
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > On Mon, Jul 25, 2011 at 10:37 AM, Michael Bedward
> >> >> > <[email protected]> wrote:
> >> >> >>
> >> >> >> Hello Apurv,
> >> >> >>
> >> >> >> > I am absolutely new to the geo tool library. In fact I want to
> >> >> >> > use
> >> >> >> > it
> >> >> >> > for a
> >> >> >> > specific purpose in the open source project "phyloGeoRef".
> >> >> >>
> >> >> >> Great to see taxonomy / biogeography making an appearance here :)
> >> >> >>
> >> >> >> > Here is the
> >> >> >> > functionality that I want.
> >> >> >>
> >> >> >> > Given a set of (lat,long) pairs on the globe. I have to
> calculate
> >> >> >> > the
> >> >> >> > inside
> >> >> >> > point replacer for these set of nodes. Is there some function in
> >> >> >> > Geo
> >> >> >> > Tools
> >> >> >> > that provides this functionality. If not, Is there any other
> >> >> >> > method
> >> >> >> > to
> >> >> >> > do it
> >> >> >> > ?
> >> >> >>
> >> >> >> Can you provide more detail about the required output. I'm not
> >> >> >> familiar with the term "inside point replacer" and Wikipedia
> doesn't
> >> >> >> seem to know it either. Is it a type of centroid calculation ?
> >> >> >>
> >> >> >> Michael
> >> >> >
> >> >> >
> >> >
> >> >
> >
> >
>
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users