karl.r
karl.r

Reputation: 971

Get bounding box of coordinates, ignoring fringe locations

I'm trying to create a bounding box around a set of coordinates, but I want to 'focus' on groups of coordinates and ignore any that are way off and would mess up the map. (Imagine a map of 10 spots on a city and 1 somewhere in another country)

What would be the best way to build the top-left and bottom-right values?

Upvotes: 2

Views: 1422

Answers (3)

Matthew
Matthew

Reputation: 10444

First I would determine your criteria for "fringe locations"

Something like "outside 2 σ" then you just need to calculate your mean in both dimensions and draw your lines at 2σ. If you want some curvy boundary then things get much more complicated... Start at your criteria and move forward from there.

So let's assume you wanted to exclude things more than 2σ from the mean

You need to calculate:

σ(x), σ(y), mean(x), mean(y)

Then your upper left bound is ( mean(x)-2σ(x) , mean(y)+2σ(y) )

and your lower right bound is ( mean(x)+2σ(x) , mean(y)-2σ(y) )

this will yield a rectangle for 2σ in both dimensions. For a circle things will get a bit more complicated... start with defining you "acceptable region"

Upvotes: 2

MarioVW
MarioVW

Reputation: 2524

Put to work what you learned in your statistics courses; e.g.:

  1. Calculate the mean of your X and Y coordinates
  2. Calculate the standard deviation (X and Y)
  3. Discard items that are more than two stdevs from your mean
  4. Calculate your bounding box based on the resulting coordinates

Upvotes: 0

Jim Mischel
Jim Mischel

Reputation: 134005

Compute the centroid, and then pick the point that's nearest that centroid. Then, throw out any point that's more than some constant distance (or, perhaps, some threshold like one or two standard deviations away from that point). Now, re-compute using the trimmed set of points. Do that until you're happy with the result (i.e. all points are within the boundaries that you define).

As Matthew PK said, this will work will for a simple radius, but if you want some type of curved boundary, it's a lot of additional work.

Upvotes: 0

Related Questions