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.


In reply to Is a point in a polygon? by ferddle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.