Re: Point within country boundary [message #87320 is a reply to message #87319] |
Fri, 24 January 2014 11:08   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Matt writes:
> I'm trying to find out which countries a set of points fall within. I thought I could do this using the supplied map shapefiles and IDLanROI. However, when I try this:
>
> country_path = "/usr/local/exelis/idl/resource/maps/shape/country.shp"
>
> oSHP = OBJ_NEW('IDLffShape', country_path )
> ent1 = oSHP -> GetEntity( 34, /ATTRIBUTES ) ;USA
> OBJ_DESTROY, oSHP
>
> oROI = OBJ_NEW('IDLanROI', (*ent1.vertices))
> test = oROI -> ContainsPoints([-100.], [35.])
> OBJ_DESTROY, oROI
>
> print, test
>
> ... I get 0, whereas I'm pretty sure -100E, 35W should be within the USA.
>
> Am I misunderstanding how these objects or shape files should be used?
>
> Thanks in advance for any pointers,
It is a little more complicated than that. :-)
When I extract the USA shape from that file with cgExtractShape, I get
back an IDLanROIGroup object that contains 59 separate IDLanROI objects.
You are probably not looking in the right one. ;-)
http://www.idlcoyote.com/code_tips/extractpoly.php
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|