Re: [gdal-dev] Tests if the geometry is within the other geometry

2018-06-23 Thread Even Rouault
On samedi 23 juin 2018 04:21:38 CEST Ian wrote: > I have a shape file consisting of thousands of features/polygons. > I have to extract only those polygons which are within the reference > polygon. > > I tried as follows: > > refpoly = feat.GetGeometryRef() > > fi = 'data.shp' > ids = ogr.Open(

Re: [gdal-dev] Tests if the geometry is within the other geometry

2018-06-22 Thread Ian
inlay.SetSpatialFilter(refpoy) did not meet my requirement of "if geomi.Within(refpoly)". if I use both inlay.SetSpatialFilter(refpoy) and geomi.Within(refpoly), speed is same as before. .SetSpatialFilter tested intersect of the envelopes, which i do not need. any idea is appreciated On Sat, J

Re: [gdal-dev] Tests if the geometry is within the other geometry

2018-06-22 Thread mikeucfl
Use a spatial filter using your refpoly before iterating the features: http://gdal.org/python/osgeo.ogr.Layer-class.html#SetSpatialFilter -- Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html ___ gdal-dev mailing list gdal-dev@lists.

[gdal-dev] Tests if the geometry is within the other geometry

2018-06-22 Thread Ian
I have a shape file consisting of thousands of features/polygons. I have to extract only those polygons which are within the reference polygon. I tried as follows: refpoly = feat.GetGeometryRef() fi = 'data.shp' ids = ogr.Open(fi,0) inlay = ids.GetLayer(0) for feat in inlay: ctype = feat.Ge