anthirini

Reading the record values in several specific locations of a shapefile

Discussion created by anthirini on Nov 29, 2012
Latest reply on Nov 29, 2012 by anthirini
Hello everyone!

I have tried the following 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.

Outcomes