[Shapelib] Identify polygon by XY coordinate?
shapelib-admin at lists.maptools.org
shapelib-admin at lists.maptools.org
Wed Mar 17 07:37:35 PST 2004
shapelib-admin at lists.maptools.org wrote:
> List,
> I need a function that uses (X,Y) coordinates to identify the
> surrounding polygon in a shapefile, and then retrieve the associated
> attribute information for that polygon.
> Does anyone have a function like that?
Bob,
The ogrinfo utility will approximately do this; however, it doesn't do
real point-in-polygon tests, it just verifies that the bounding box of
the polygon(s) intersects the target point(or region). If that is
sufficient then you would use something like:
ogrinfo -ro -spat 481710 4752312 481710 4752312 polygon.shp polygon
http://ogr.maptools.org
There is a point-in-polygon available in the CVS version of Shapelib if you
would like to construct a program to do this yourself. I haven't tried the
point in polygon code, but I assume it works ok. It may require some digging
to figure out how to use it and build an app to do the full operation.
I have attached the readme and code I received for this. It should work with
a regular release shapelib.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Shape_PointInPoly.cpp
URL: <http://lists.osgeo.org/pipermail/shapelib/attachments/20040317/bc8e21cc/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Shape_PointInPoly_README.txt
URL: <http://lists.osgeo.org/pipermail/shapelib/attachments/20040317/bc8e21cc/attachment.txt>
More information about the Shapelib
mailing list