def generate_tiles(self):
"""INCOMPLETE Split the calculated WPbm in 100 tiles facilitating the export
Returns:
TYPE: Description
"""
driver = ogr.GetDriverByName('ESRI Shapefile')
dir_shps = "tiles"
os.chdir(dir_shps)
file_shps = glob.glob("*.shp")
allExportWPbm = []
file_names = []
for file_shp in file_shps:
dataSource = driver.Open(file_shp, 0)
if dataSource is None:
sys.exit(('Could not open {0}.'.format(file_shp)))
else:
layer = dataSource.GetLayer(0)
extent = layer.GetExtent()
active_file = "tile_" + str(file_shp.split('.')[0]).split("_")[3]
file_names.append(active_file)
low_sx = extent[0], extent[3]
up_sx = extent[0], extent[2]
up_dx = extent[1], extent[2]
low_dx = extent[1], extent[3]
cut = [list(low_sx), list(up_sx), list(up_dx), list(low_dx)]
Export_WPbm = {
"crs": "EPSG:4326",
"scale": 250,
'region': cut}
allExportWPbm.append(Export_WPbm)
return allExportWPbm, file_names
评论列表
文章目录