Commit 24a25f50 authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Added get_union and get_intersection methods to PolygonData.

git-svn-id: https://svn.seismo.oma.be/svn/seismo/mapping/layeredbasemap/trunk@6043 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent 161be8dc
......@@ -242,6 +242,44 @@ class PolygonData(SingleData):
overlapping_area = 0.
return overlapping_area / original_area
def get_union(self, other_pg):
"""
Construct union with other polygon
:param other_pg:
instance of :class:`PolygonData`
:return:
instance of :class:`PolygonData`
"""
assert isinstance(other_pg, self.__class__)
ogr_geom = self.to_ogr_geom()
other_ogr_geom = other_pg.to_ogr_geom()
union = ogr_geom.Union(other_ogr_geom)
return self.from_ogr(union)
def get_intersection(self, other_pg):
"""
Construct intersection with other polygon
:param other_pg:
instance of :class:`PolygonData`
:return:
instance of :class:`PolygonData`
"""
assert isinstance(other_pg, self.__class__)
ogr_geom = self.to_ogr_geom()
other_ogr_geom = other_pg.to_ogr_geom()
union = ogr_geom.Intersection(other_ogr_geom)
return self.from_ogr(union)
class MultiPolygonData(MultiData):
def __init__(self, lons, lats, z=None, interior_lons=None, interior_lats=None,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment