-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from NREL/feat/offshore_lcp
Feat/offshore lcp
- Loading branch information
Showing
15 changed files
with
1,772 additions
and
151 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
320 changes: 320 additions & 0 deletions
320
examples/least_cost_paths/combine_layers_and_add_to_h5.ipynb
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,320 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Combine all on- and off-shore land and barrier layers" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from reVX.least_cost_xmission.aoswt_utilities import CombineRasters" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Default layer location so we don't have to write the full path\n", | ||
"layer_dir = '/shared-projects/rev/projects/aoswt/data/exclusions'\n", | ||
"\n", | ||
"# Template raster to pull transform, etc. from\n", | ||
"template_f ='/shared-projects/rev/projects/aoswt/data/exclusions/adjusted_shipping_lanes.tif'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# The barriers have one or more values to \"bar\" in the first position of\n", | ||
"# the tuple. Single values should be an int, multiple values should use a list. \n", | ||
"# Any other values in the raster are considered open and not to be a barrier.\n", | ||
"barrier_files = [\n", | ||
" (1, 'military_ship_shock_boxes.tif'),\n", | ||
" (1, 'artificial_reefs.tif'),\n", | ||
" (1, 'danger_zones_and_restricted_areas.tif'),\n", | ||
" (1, 'usace_placement_areas.tif'),\n", | ||
" (1, 'usace_sand_borrow_areas.tif'),\n", | ||
" (1, 'usace_sad_sand_borrow_areas.tif'),\n", | ||
" (1, 'boem_sand_borrow_areas.tif'),\n", | ||
" (1, 'boem_marine_mineral_areas.tif'),\n", | ||
" (1, 'unexploded_ordnance_locations_100m_buffer.tif'),\n", | ||
" (1, 'dpp_option_areas.tif'),\n", | ||
" (3, 'dod_designations.tif'),\n", | ||
" ([1,2,3,4], 'ocean_disposal_sites.tif'),\n", | ||
" ([1,2,3,4,6], 'conservation_areas.tif'),\n", | ||
" (1, '/shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif'),\n", | ||
"]\n", | ||
"\n", | ||
"# Force include layers. These layers will override the barrier layers. Cells with values in \n", | ||
"# the first position of the tuple (int or list) will be forced \"open\" if barricaded \n", | ||
"# by the barrier_files. Cells with any other values will not be affected.\n", | ||
"fi_files = [\n", | ||
" (1, 'boem_wind_planning_areas_03292021.tif'),\n", | ||
" (1, 'boem_wind_leases_06082021.tif'),\n", | ||
" (1, 'aoswt_ad_hoc_forced_inclusions.tif'),\n", | ||
"]\n", | ||
"\n", | ||
"friction_files = [\n", | ||
" # ({'cell value in tiff': 'corresponding friction', ...}, 'filename.tif')\n", | ||
" ({1: 1, 2: 10, 3:5}, 'adjusted_shipping_lanes.tif'),\n", | ||
" ({1: 5}, 'abb_gas_pipelines_61m_buffer.tif'),\n", | ||
" ({1: 10}, 'federal_channels.tif'),\n", | ||
" ({1: 10, 2: 5, 3: 0},'/shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif'),\n", | ||
"]\n", | ||
"\n", | ||
"slope_file = 'atlantic_coast_slope.tif'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cr = CombineRasters(template_f, layer_dir=layer_dir)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Loading barrier layers\n", | ||
"--- military_ship_shock_boxes.tif\n", | ||
"--- artificial_reefs.tif\n", | ||
"--- danger_zones_and_restricted_areas.tif\n", | ||
"--- usace_placement_areas.tif\n", | ||
"--- usace_sand_borrow_areas.tif\n", | ||
"--- usace_sad_sand_borrow_areas.tif\n", | ||
"--- boem_sand_borrow_areas.tif\n", | ||
"--- boem_marine_mineral_areas.tif\n", | ||
"--- unexploded_ordnance_locations_100m_buffer.tif\n", | ||
"--- dpp_option_areas.tif\n", | ||
"--- dod_designations.tif\n", | ||
"--- ocean_disposal_sites.tif\n", | ||
"--- conservation_areas.tif\n", | ||
"--- /shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif\n", | ||
"--- calculating slope barrier\n", | ||
"Building composite off-shore barrier layers\n", | ||
"Loading forced inclusion layers\n", | ||
"--- boem_wind_planning_areas_03292021.tif\n", | ||
"--- boem_wind_leases_06082021.tif\n", | ||
"--- aoswt_ad_hoc_forced_inclusions.tif\n", | ||
"Building composite forced inclusion layers\n", | ||
"Saving barriers to os_barriers.tif\n", | ||
"Done building barrier layers\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Build composite barrier layer\n", | ||
"cr.build_off_shore_barriers(barrier_files, fi_files, slope_file=slope_file, save_tiff=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Loading friction layers\n", | ||
"--- setting raster value 1 to fricton 1 for adjusted_shipping_lanes.tif\n", | ||
"--- setting raster value 2 to fricton 10 for adjusted_shipping_lanes.tif\n", | ||
"--- setting raster value 3 to fricton 5 for adjusted_shipping_lanes.tif\n", | ||
"--- setting raster value 1 to fricton 5 for abb_gas_pipelines_61m_buffer.tif\n", | ||
"--- setting raster value 1 to fricton 10 for federal_channels.tif\n", | ||
"--- setting raster value 1 to fricton 10 for /shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif\n", | ||
"--- setting raster value 2 to fricton 5 for /shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif\n", | ||
"--- setting raster value 3 to fricton 0 for /shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif\n", | ||
"--- calculating slope friction\n", | ||
"Combining off-shore friction layers\n", | ||
"Saving combined friction to tiff\n", | ||
"Done processing friction layers\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Build composite friction layer\n", | ||
"cr.build_off_shore_friction(friction_files, slope_file=slope_file, save_tiff=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Existing AOSWT h5 file to pull lat/lng, profile from\n", | ||
"ex_aoswt_h5 = '/shared-projects/rev/projects/aoswt/data/exclusions/AOSWT_Exclusions.h5'\n", | ||
"\n", | ||
"# New AOSWT h5 file to write costs and barriers to\n", | ||
"aoswt_h5 = '/shared-projects/rev/projects/aoswt/data/processing/aoswt_costs.h5'\n", | ||
"\n", | ||
"# Existing land costs and barrier\n", | ||
"land_h5 = '/shared-projects/rev/exclusions/xmission_costs.h5'\n", | ||
"land_barrier_layer = 'transmission_barrier'\n", | ||
"land_costs_layer = 'tie_line_costs_102MW'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create new AOSWT h5 file if needed\n", | ||
"if False:\n", | ||
" cr.create_aoswt_h5(ex_aoswt_h5, aoswt_h5, overwrite=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Rasterizing /shared-projects/rev/projects/aoswt/data/shapefiles/coast/gshhs_f_l1_rev.shp\n", | ||
"Saving land mask to land_mask.tif\n", | ||
"Rasterizing complete\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Convert coastal boundary shp file to mask if not already done\n", | ||
"if False:\n", | ||
" land_shp = '/shared-projects/rev/projects/aoswt/data/shapefiles/coast/gshhs_f_l1_rev.shp'\n", | ||
" cr.create_land_mask(land_shp, save_tiff=True)\n", | ||
"else:\n", | ||
" cr.load_land_mask()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Loading land barriers \"transmission_barrier\" from /shared-projects/rev/exclusions/xmission_costs.h5\n", | ||
"Reprojecting land barriers\n", | ||
"Combining land and off-shore barriers\n", | ||
"Saving combined barriers to combo_barriers.tif\n", | ||
"Writing combined data to \"transmission_barrier\" in /shared-projects/rev/projects/aoswt/data/processing/aoswt_costs.h5\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Merge barriers and write to h5\n", | ||
"cr.merge_os_and_land_barriers(land_h5, land_barrier_layer, aoswt_h5, save_tiff=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 14, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Loading land friction \"tie_line_costs_102MW\" from /shared-projects/rev/exclusions/xmission_costs.h5\n", | ||
"Reprojecting land friction\n", | ||
"Combining land and off-shore friction\n", | ||
"Saving combined friction to combo_friction.tif\n", | ||
"Writing combined data to \"tie_line_costs_102MW\" in /shared-projects/rev/projects/aoswt/data/processing/aoswt_costs.h5\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Merge frictions and write to h5\n", | ||
"cr.merge_os_and_land_friction(land_h5, land_costs_layer, aoswt_h5, \n", | ||
" land_cost_mult=1/15000, save_tiff=True) # just right?\n", | ||
" # land_cost_mult=1/10000, save_tiff=True) # too expensive (from first run)\n", | ||
" # land_cost_mult=1/25000, save_tiff=False) #better, still too cheap\n", | ||
" # land_cost_mult=1/50000, save_tiff=True) # to cheap\n", | ||
" # land_cost_mult=1/75000, save_tiff=True) #to cheap, full paths around cape cod\n", | ||
" # land_cost_mult=1/100000, save_tiff=True) # to cheap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.