Re: Finding a points inside polygon [message #32629] |
Thu, 24 October 2002 08:17  |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
James Kuyper wrote:
>
> Gunho Sohn wrote:
>>
>> Dear All,
>>
>> I have a problem to determine whether a point (x,y) is inside the polygon.
>> Simply I've used IDLanROI::ContainsPoints method in my code. However, it
>> seems to make a serious problem. Please, check this problem together. I used
>> following polygons and point
>>
>> polygon vertices (vx,vy):
>> vx=[35.859278 55.591451 155.00000 155.00000]
>> vy=[0.00000000 0.00000000 19.279154 23.105984]
>>
>> point (x,y):
>> x=122.87897 y=13.049367
>>
>> When I simply coded this as follows, it printes as 0 which means this point
>> is located outside of polygon. But, it is not!
By the way, the range of values you were using made me wonder - by any
chance are those values geographic latitudes and longitudes? In that
case, you have to be very careful about how you define your polygon
edges. Each map projection constitutes a different definition of what it
means to be a "straight line". The most natural definition is that the
edges are great circle arcs. In that case, to see the boundaries of your
polygon properly, you need to use the gnomonic projection, because it's
the only one that maps all great circle arcs as straight lines. Try the
following:
IDL> map_set,21.0,92.0,/gnomic,/continents,/grid,/label,scale=2e8
IDL> oplot,vx,vy
That will give you the overview of the problem. To get down to the
details, use:
IDL> map_set,13.049367,122.87897,/gnomic,/hires,/grid,/label,scal e=2e7
IDL> oplot,vx,vy
IDL> plots,122.87897,13.049367, psym=2
So, if these are latitude-longitude values connected by great circle
arcs, the specified point is not merely outside the polygon, it's
hundreds of miles outside the polygon.
|
|
|