def _get_intersection(self, trg=None, idx=None, buf=0.):
"""Just a toy function if you want to inspect the intersection
points/polygons of an arbitrary target or an target by index.
"""
# TODO: kwargs necessary?
# check wether idx is given
if idx is not None:
if self.trg:
try:
lyr = self.trg.ds.GetLayerByName('trg')
feat = lyr.GetFeature(idx)
trg = feat.GetGeometryRef()
except Exception:
raise TypeError("No target polygon found at index {0}".
format(idx))
else:
raise TypeError('No target polygons found in object!')
# check for trg
if trg is None:
raise TypeError('Either *trg* or *idx* keywords must be given!')
# check for geometry
if not type(trg) == ogr.Geometry:
trg = georef.numpy_to_ogr(trg, 'Polygon')
# apply Buffer value
trg = trg.Buffer(buf)
if idx is None:
intersecs = self.src.get_data_by_geom(trg)
else:
intersecs = self.dst.get_data_by_att('trg_index', idx)
return intersecs
评论列表
文章目录