Prev: Install problem: error while loading shared libraries: libXp.so.6
Next: Face Detection with Adaboost using Matlab
From: Splijin on 17 Jun 2005 11:13 Given vector map data containing latitude and longitude locations for a boundary, how do I go about checking if a supplied lat/lon is inside or outside the prescribed boundary? For example: >> states = shaperead('usastatelo', 'UseGeoCoords', true); 'states(1).Lat' and 'states(1).Lon' contain the latitude and longitude coordinates (105 points in all) for Alabama's border/boundary. And the following allows all the states boundaries to be plotted and even colored individually. >> ax = worldmap('USA'); >> faceColors = makesymbolspec('Polygon',... {'Number', [1 numel(states)], 'FaceColor', >> polcmap(numel(states))}); >> geoshow(ax, states, 'DisplayType', 'polygon', ... 'SymbolSpec', faceColors) Surely if there is a way to color the inside of the boundary there is a way to check and see if a particular lat/lon resides within the borders/boundary? I haven't been able to come across anything regarding this in the help files, any help would be greatly appreciated. Thanks.
From: us on 17 Jun 2005 11:57 Splijin: <SNIP who's-in-who's-out evergreen... a hint: help inpolygon us
From: Kelly on 17 Jun 2005 13:04
Splijin wrote: > Given vector map data containing latitude and longitude locations > for > a boundary, how do I go about checking if a supplied lat/lon is > inside or outside the prescribed boundary? .... > Surely if there is a way to color the inside of the boundary there > is > a way to check and see if a particular lat/lon resides within the > borders/boundary? us mentioned the inpolygon function. You may be interested in a function I wrote called inpolygons.m (available in the file exchange), which I originally wrote to deal with determining values at points based on shapefile data. Keep in mind that if the polygon you are dealing with is too large, inpolygon (and inpolygons also) may not be completely accurate due to the curvature of the earth. To deal with this, you could use track to redefine your polygon line segments at a higher resolution. Crossing the poles will cause problems too; look at flatearthpoly to modify this type of polygon. -Kelly |