[GRASS-SVN] r58624 - grass/trunk/lib/python/pygrass/modules/grid
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 6 09:32:54 PST 2014
Author: zarch
Date: 2014-01-06 09:32:54 -0800 (Mon, 06 Jan 2014)
New Revision: 58624
Modified:
grass/trunk/lib/python/pygrass/modules/grid/split.py
Log:
Add a function to get the overlapped regions
Modified: grass/trunk/lib/python/pygrass/modules/grid/split.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/grid/split.py 2014-01-06 17:31:15 UTC (rev 58623)
+++ grass/trunk/lib/python/pygrass/modules/grid/split.py 2014-01-06 17:32:54 UTC (rev 58624)
@@ -53,3 +53,38 @@
row_list.append(get_bbox(reg, row, col, width, height, overlap))
box_list.append(row_list)
return box_list
+
+
+def get_overlap_region_tiles(region=None, width=100, height=100, overlap=0):
+ """Get the Bbox ov the overlapped region. ::
+
+ >>> reg = Region()
+ >>> reg.north = 1350
+ >>> reg.south = 0
+ >>> reg.nsres = 1
+ >>> reg.east = 1500
+ >>> reg.west = 0
+ >>> reg.ewres = 1
+ >>> reg.cols
+ 1500
+ >>> reg.rows
+ 1350
+ >>> split_region_tiles(region=reg, width=1000, height=700, overlap=0)
+ [[Bbox(1350.0, 650.0, 1000.0, 0.0), Bbox(1350.0, 650.0, 1500.0, 1000.0)],
+ [Bbox(650.0, 0.0, 1000.0, 0.0), Bbox(650.0, 0.0, 1500.0, 1000.0)]]
+ >>> split_region_tiles(region=reg, width=1000, height=700, overlap=10)
+ [[Bbox(1350.0, 640.0, 1010.0, 0.0), Bbox(1350.0, 640.0, 1500.0, 990.0)],
+ [Bbox(660.0, 0.0, 1010.0, 0.0), Bbox(660.0, 0.0, 1500.0, 990.0)]]
+ """
+ reg = region if region else Region()
+ ncols = (reg.cols + width - 1) // width
+ nrows = (reg.rows + height - 1) // height
+ box_list = []
+ #print reg
+ for row in xrange(nrows):
+ row_list = []
+ for col in xrange(ncols):
+ #print 'c', c, 'r', r
+ row_list.append(get_bbox(reg, row, col, width, height, -overlap))
+ box_list.append(row_list)
+ return box_list
More information about the grass-commit
mailing list