def main():
	"""Process hazard data

    1. Specify the paths from where to read and write:
        - Input data
        - Hazard data

    2. Supply input data and parameters
        - Thresholds of flood hazards
        - Values of bands to be selected
        - Color code of multi-band rasters
        - Specific file names that might require some specific operations
    """
	data_path = load_config()['paths']['data']
	root_dir = os.path.join(data_path,'flood_data','FATHOM')

	thresholds = [1,2,3,4,999]
	thresholds_label = ['50cm','1m','2m','3m','4m','999m']
	f_all = []
	for root, dirs, files in os.walk(root_dir):
		for file in files:
			if file.endswith(".tif") or file.endswith(".tiff"):
				band_nums, crs = raster_projections_and_databands(os.path.join(root, file))
				print (file,band_nums,crs)
				if 'epsg' in crs:
					crs_split = crs.split(':')
					s_crs = [int(c) for c in crs_split if c.isdigit() is True][0]
				else:
					s_crs = 4326


				# threshold based datasets
				for t in range(len(thresholds)-1):
					thr_1 = thresholds[t]
					thr_2 = thresholds[t+1]
					in_file = os.path.join(root,file)
					tmp_1 = os.path.join(root,file.split(".tif")[0] + '_mask.tiff')
					tmp_2 = os.path.join(root,file.split(".tif")[0] + '_mask.shp')
					out_file = os.path.join(root,file.split(".tif")[0] + \
								'_{0}-{1}_threshold.shp'.format(thresholds_label[t],thresholds_label[t+1]))
					convert_geotiff_to_vector_with_threshold(thr_1,thr_2,in_file,s_crs,tmp_1, tmp_2, out_file)
Ejemplo n.º 2
0
        facecolor=colors['Waterway'],
        zorder=4
    )

    # nodes
    nodes = geopandas.read_file(water_node_file)
    nodes = nodes[nodes['name']!='none']
    ax.scatter(
        list(nodes.geometry.x),
        list(nodes.geometry.y),
        transform=proj_lat_lon,
        facecolor=colors['Port'],
        s=4,
        zorder=5
    )

    # legend
    legend_handles = [
        mpatches.Patch(color=color, label=label)
        for label, color in colors.items()
    ]
    plt.legend(handles=legend_handles, loc='lower left')

    # save
    save_fig(output_file)


if __name__ == '__main__':
    CONFIG = load_config()
    main(CONFIG)