Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Reading the record values in several specific locations of a shapefile

$
0
0
Hello everyone!

I have tried the following code:

Code:

from osgeo import ogr

LandUse = ogr.Open("C:\\Python26\\ArcGIS10.0\\landuse shpfile (polygon)\\landuse.shp")
lyr = LandUse.GetLayerByName("landuse data_ypan")
lyr.ResetReading()
point = ogr.CreateGeometryFromWkt("POINT(503234.931458 3443753.43622)")
for feat in lyr:
    geom = feat.GetGeometryRef()
    if geom.Contains(point):
        sm = feat.GetField(feat.GetFieldIndex("Land_Group"))
        print sm

I am wondering if there is the possibility to import variables X, Y in the place of the number coordinates (red coloured text) in order to perform a for loop among several x, y coordinates.

Thank you very much.

Viewing all articles
Browse latest Browse all 2485

Trending Articles