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
points = [] f = open('C:\\coords.txt', 'r') for line in f.readlines(): x, y = [coord.strip() for coord in line.split(';')] #suppose coords are delimited with semicolons points.append((float(x), float(y))) f.close()
from osgeo import ogr LandUse = ogr.Open("C:\\Python26\\ArcGIS10.0\\landuse shpfile (polygon)\\landuse.shp") lyr = LandUse.GetLayerByName("landuse data_ypan") lyr.ResetReading() points = [(x1,y1), (x2, y2),...,(xn, yn)] for coords in points: point = ogr.CreateGeometryFromWkt("POINT(%f %f)" % coords) for feat in lyr: geom = feat.GetGeometryRef() if geom.Contains(point): sm = feat.GetField(feat.GetFieldIndex("Land_Group")) print sm
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.