-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for flood height to raster processor
- Loading branch information
ms-michelle-zhang
committed
Dec 7, 2020
1 parent
430f743
commit 13c0abd
Showing
38 changed files
with
3,032 additions
and
683 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
183 changes: 183 additions & 0 deletions
183
.ipynb_checkpoints/Flood Height to Raster Processor-checkpoint.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,183 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Flood Height to Raster Processor" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This code takes flood heights and DEMs as inputs and uses the ArcGIS Con function and MosaictoRaster function to find the inundated areas for each division and output them as a binary raster of flooded or not flooded for each division and the entire area of interest." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2020-12-07T22:43:07.414240Z", | ||
"start_time": "2020-12-07T22:43:07.090067Z" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"ename": "ModuleNotFoundError", | ||
"evalue": "No module named 'arcpy'", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", | ||
"\u001b[1;32m<ipython-input-1-0ac1e8c99165>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0marcpy\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0marcpy\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0menv\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0marcpy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msa\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[1;33m*\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mpandas\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mpd\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | ||
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'arcpy'" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import arcpy\n", | ||
"from arcpy import env\n", | ||
"from arcpy.sa import *\n", | ||
"import pandas as pd\n", | ||
"import os" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Import csvs" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"flood_heights_c = pd.read_csv(\"Sample_Output_Data\\\\single_storm_flood_heights_c.csv\",header=None).values[0]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Create rasters" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<h2>Output</h2>Sample_Output_Data\\Flood_Rasters_w\\Inundation_areas_w.tif<h2>Messages</h2>Start Time: Monday, November 16, 2020 9:17:44 AM<br/>IntermediateData\\div_Rasters\\storm_cold_div0.TIF is loading...<br/>Succeeded at Monday, November 16, 2020 9:17:44 AM (Elapsed Time: 0.15 seconds)<br/><style>.rendered_html td, .rendered_html th {text-align: left;}.rendered_html tbody {border: 1px solid black;}</style>" | ||
], | ||
"text/plain": [ | ||
"<Result 'Sample_Output_Data\\\\Flood_Rasters_w\\\\Inundation_areas_w.tif'>" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"#Warm Storm\n", | ||
"\n", | ||
"# location of original, divisioned, DEM files\n", | ||
"env.workspace = r\"Data\\LM_div18\"\n", | ||
"env.overwriteOutput = True\n", | ||
"\n", | ||
"rasters=[]\n", | ||
"\n", | ||
"divfolder = r\"IntermediateData\\div_Rasters\"\n", | ||
"if not os.path.exists(divfolder):\n", | ||
" os.makedirs(divfolder)\n", | ||
"rasterfolder = r\"Sample_Output_Data\\Flood_Rasters_w\"\n", | ||
"if not os.path.exists(rasterfolder):\n", | ||
" os.makedirs(rasterfolder)\n", | ||
"\n", | ||
"#Processing Warm Storms\n", | ||
"for i in range(len(flood_heights_w)):\n", | ||
" raster_name=r\"Data\\LM_div18\\dem_lm_z35_%d.TIF\"%i\n", | ||
" inRaster = Raster(raster_name)\n", | ||
" whereClause=\"VALUE<%f\"%flood_heights_w[i]\n", | ||
" outCon = Con(inRaster, 1, 0, whereClause)\n", | ||
" outPath = r\"IntermediateData\\div_Rasters\\storm_cold_div%d.TIF\"%i\n", | ||
" outCon.save(outPath)\n", | ||
" rasters.append(outPath)\n", | ||
"\n", | ||
"arcpy.MosaicToNewRaster_management(rasters, rasterfolder , \"Inundation_areas_w.tif\",None,None,None,1,None,None)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"hide_input": false, | ||
"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.8.3" | ||
}, | ||
"toc": { | ||
"base_numbering": 1, | ||
"nav_menu": {}, | ||
"number_sections": true, | ||
"sideBar": true, | ||
"skip_h1_title": false, | ||
"title_cell": "Table of Contents", | ||
"title_sidebar": "Contents", | ||
"toc_cell": false, | ||
"toc_position": {}, | ||
"toc_section_display": true, | ||
"toc_window_display": true | ||
}, | ||
"varInspector": { | ||
"cols": { | ||
"lenName": 16, | ||
"lenType": 16, | ||
"lenVar": 40 | ||
}, | ||
"kernels_config": { | ||
"python": { | ||
"delete_cmd_postfix": "", | ||
"delete_cmd_prefix": "del ", | ||
"library": "var_list.py", | ||
"varRefreshCmd": "print(var_dic_list())" | ||
}, | ||
"r": { | ||
"delete_cmd_postfix": ") ", | ||
"delete_cmd_prefix": "rm(", | ||
"library": "var_list.r", | ||
"varRefreshCmd": "cat(var_dic_list()) " | ||
} | ||
}, | ||
"types_to_exclude": [ | ||
"module", | ||
"function", | ||
"builtin_function_or_method", | ||
"instance", | ||
"_Feature" | ||
], | ||
"window_display": false | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.