Solved

# How to identify x,y coordinates that lie within a closed polygon whose vertices are defined by  x,y coordinates

Posted on 2011-09-14
404 Views
I have a set of shapes in a field, each with known x,y coordinates, height and width.

I wish to select a subset of these shapes whose centres lie within a closed polygonal line with known coordinates to its vertices.

I program in  VBA and unfortunately am not multi-lingual. However, given the principles, I'd hope to progress to write it in vba.

Thanks!
Kelvin4

0
Question by:Kelvin4
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 55

Assisted Solution

Huseyin KAHRAMAN earned 334 total points
ID: 36537722
0

LVL 86

Assisted Solution

Mike Tomlinson earned 166 total points
ID: 36537736
You could use GDI objects.  Create a Region from your known vertices then hit-test with PtInRegion():
http://msdn.microsoft.com/en-us/library/dd183511(VS.85).aspx
http://msdn.microsoft.com/en-us/library/dd162883(VS.85).aspx
0

LVL 55

Accepted Solution

Huseyin KAHRAMAN earned 334 total points
ID: 36537745
from page above:

Ray casting algorithm

The number of intersections for a ray passing from the exterior of the polygon to any point, if odd, shows the point lies inside the polygon. If the even, the point lies outside the polygon; this test also works in three dimensions.
One simple way of finding whether the point is inside or outside a simple polygon is to test how many times a ray starting from the point intersects the edges of the polygon. If the point in question is not on the boundary of the polygon, the number of intersections is an even number if the point is outside, and it is odd if inside.
0

Author Closing Comment

ID: 36548355
Thanks!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This algorithm (in C#) will resize any image down to a given size while maintaining the original aspect ratio. The maximum width and max height are both optional but if neither are given, the original image is returned. This example is designed t…
One of Google's most recent algorithm changes affecting local searches is entitled "The Pigeon Update." This update has dramatically enhanced search inquires for the keyword "Yelp." Google searches with the word "Yelp" included will now yield Yelp a…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
###### Suggested Courses
Course of the Month3 days, 21 hours left to enroll