Created
November 22, 2014 21:23
Revisions
-
David Quinn created this gist
Nov 22, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ from django.contrib.gis.geos import GEOSGeometry # sample data geom_1 = GEOSGeometry('POLYGON((-71.8 42.1,-70.6 42.1,-70.5 41.2,-71.8 41.2,-71.8 42.1))') geom_2 = GEOSGeometry('POLYGON((-71.12 42.23,-71.48 42.34,-71.52 42.55,-71.12 42.23))') geom_3 = GEOSGeometry('POLYGON((-73.12 42.23,-71.48 42.34,-71.52 42.55,-73.12 42.23))') polygons = [geom_1, geom_2, geom_3] # get first polygon polygon_union = polygons[0] # update list polygons = polygons[1:] # loop through list of polygons for poly in polygons: polygon_union = polygon_union.union(poly)