ferddle has asked for the wisdom of the Perl Monks concerning the following question:
This should be an easy question but I have hit a brick wall with my code. I greatly appreciate any response...
I work extensively with GoogleEarth files that contain both points and polygons. I have assigned two arrays for each X and Y coordinate for the points file. The arrays look something like this:
For the following coordinates:(-12, -83),(0, 34),(23, -76)
@pnt_x_values = (-12, 0, 23)
@pnt_y_values = (-83, 34, -76)
I would like to find any points that lie within any of the polygons. I have stripped the polygon file into four arrays. Each consecutive element of each array contains the minimum and maximum values for the x and y coordinates for each polygon.
The sample below uses three (rectangular) polygons:
@poly_x_min = (-13, 45, 22)
@poly_x_max = (-11, 49, 24)
@poly_y_min = (-82, 33, -2)
@poly_y_max = (-84, 35, -6)
In other words, the first point coordinate lies within the first polygon. ie:
$poly_x_min[0] <= $pnt_x_values[0] <= $poly_x_max[0]
and
$poly_y_min[0] <= $pnt_y_values[0] <= $poly_y_max[0]
(In the file, there is no nice correlation between indexes like this.)I have posted a horrible illustration here
If you have any ideas, on how to get perl to evaluate each point against each polygon in this manner, I would greatly appreciate it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is a point in a polygon?
by sandboxed (Sexton) on Apr 30, 2008 at 08:46 UTC | |
|
Re: Is a point in a polygon?
by grizzley (Chaplain) on Apr 30, 2008 at 08:50 UTC | |
|
Re: Is a point in a polygon?
by BrowserUk (Patriarch) on Apr 30, 2008 at 13:12 UTC | |
|
Re: Is a point in a polygon?
by apl (Monsignor) on Apr 30, 2008 at 09:41 UTC | |
|
Re: Is a point in a polygon?
by Anonymous Monk on Apr 30, 2008 at 08:33 UTC | |
|
Re: Is a point in a polygon?
by GrandFather (Saint) on Apr 30, 2008 at 09:54 UTC | |
by grizzley (Chaplain) on Apr 30, 2008 at 11:07 UTC | |
by GrandFather (Saint) on Apr 30, 2008 at 12:31 UTC | |
|
Re: Is a point in a polygon?
by Anonymous Monk on Apr 30, 2008 at 08:37 UTC |