> I am a newbie to OGR/OSR using Python 2.7.2, please excuse my ignorance:
> I am trying to find the distance to the closest polygon for each point.
> Is there a more efficient way than simply computing the distance to all
> polygons for each point?  For example:
>

nPts = pointsLayer.GetFeatureCount()
nPolys = polysLayer.GetFeatureCount()

for pt in range(0,nPts):
      minDist = 1000000
      pointFeature = pointsLayer.GetFeature(pt)
      for poly in range(0,nPolys):
            polyFeature = polysLayer.GetFeature(poly)
            Dist = pointFeature.GetGeometryRef().Distance(
polyFeature.GetGeometryRef() )
            if (Dist < minDist):
                  minDist = Dist
      print (pt,minDist)

Thank you.

Dave Verbyla
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to