comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » contour and points
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
contour and points [message #76734] Mon, 27 June 2011 18:38 Go to next message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
Hi all,

What's the easiest/best way to find out if a point lies inside or
outside a closed contour? My contours were created using cgcontour.
Thanks!

--Gray
Re: contour and points [message #76781 is a reply to message #76734] Fri, 01 July 2011 05:58 Go to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Jun 29, 12:36 pm, Michael Galloy <mgal...@gmail.com> wrote:
> On 6/29/11 5:43 AM, Andy Heaps wrote:
>
>> A user of mine came to me with a similar problem: how do I find whether
>> a point is inside a country outline? Her example was Norway. I suggested
>> that she plots the points by number and sees which points are within the
>> outline of Norway. As she was just using one set of points and one
>> country this is easier to do by eye. If you have multiple countries
>> and/or grid points to check this method is too laborious. For the
>> generalised case I'd open a Z buffer image plot, plot and fill the
>> country and then check whether your point was the filled colour or
>> background colour.
>
> A general way of determining if a point is inside a closed path is to
> use IDLanROI::containsPoints:
>
> [501]> path_x = [0, 1, 1, 0, 0]
> [502]> path_y = [0, 0, 1, 1, 0]
> [503]> roi = obj_new('IDLanROI', path_x, path_y)
> [504]> print, roi->containsPoints([0.5, 1.5, 1.0], [0.5, 0.5, 0.5])
>         1       0       2
>
> The result means: 0 = outside, 1 = inside, 2 = on edge.
>
> Mike
> --
> Michael Galloywww.michaelgalloy.com
> Modern IDL, A Guide to Learning IDL:http://modernidl.idldev.com
> Research Mathematician
> Tech-X Corporation

Yes, Mike -- that's exactly what I ended up doing. I grabbed the
contour information using the path_xy, path_info, and path_data_coords
keywords, and created an IDLanROI of the relevant contour and used
ContainsPoints. It works great!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: ps_start, window problem
Next Topic: A problem with the group?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:55:17 PDT 2025

Total time taken to generate the page: 0.00495 seconds