Skip to content

Commit

Permalink
Majority UTM & images
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lewis committed Oct 30, 2020
1 parent 34f50a4 commit 99b23a4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
Binary file added DEM-HUC12-Availability.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DEM-HUC12-Outputs_example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 14 additions & 20 deletions geoflood-preprocessing-1m-mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,13 @@ def unique(shape):

shape.to_crs('epsg:4326',inplace=True)

shape['min'] = list(zip(shape.bounds['miny'],shape.bounds['minx']))
uniq_min = shape['min'].apply(lambda x: utm.latlon_to_zone_number(*x)).unique()
shape.drop(columns=['min'],inplace=True)

shape['max'] = list(zip(shape.bounds['maxy'],shape.bounds['maxx']))
uniq_max = shape['max'].apply(lambda x: utm.latlon_to_zone_number(*x)).unique()
shape.drop(columns=['max'],inplace=True)
#del(shape)

uniq = np.unique(np.append(uniq_min,uniq_max))
#del(uniq_min,uniq_max)
if uniq.shape[0] > 1:
print("ERROR: Cross-UTM input shapefile not yet supported.")
sys.exit(0)
## TODO: make this majority count an option
## and bring back cross-utm error as default behaviour
uniq = shape.representative_point().apply(lambda p: utm.latlon_to_zone_number(p.y,p.x)).value_counts().idxmax()

#if uniq.shape[0] > 1:
# print("ERROR: Cross-UTM input shapefile not yet supported.")
# sys.exit(0)

return(uniq)

Expand All @@ -246,26 +239,27 @@ def unique(shape):

## Are the catchments all within the same UTM?
uniq = unique(hu12catchs)
print(type(uniq))

## Buffer the HUC12 catchments
if hu12catchs.crs.datum.name=='World Geodetic System 1984':
#crs = CRS(proj='utm', zone=uniq[0], datum='WGS84')
if uniq[0]==13:
if uniq==13:
crs = 'epsg:32613'
elif uniq[0]==14:
elif uniq==14:
crs = 'epsg:32614'
elif uniq[0]==15:
elif uniq==15:
crs = 'epsg:32615'
else:
print("ERROR: UTMs outside of 13-15 not yet supported.")
sys.exit(0)
elif hu12catchs.crs.datum.name=='North American Datum 1983' or hu12catchs.crs.datum.name=='D_NORTH_AMERICAN_1983' or hu12catchs.crs.datum.name=='NAD83 (National Spatial Reference System 2011)':
#crs = CRS(proj='utm', zone=uniq[0], datum='NAD83')
if uniq[0]==13:
if uniq==13:
crs = 'epsg:6342'
elif uniq[0]==14:
elif uniq==14:
crs = 'epsg:6343'
elif uniq[0]==15:
elif uniq==15:
crs = 'epsg:6344'
else:
print("ERROR: UTMs outside of 13-15 not yet supported.")
Expand Down
13 changes: 11 additions & 2 deletions geoflood-preprocessing-1m-mp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@ module unload python2
eval "$(conda shell.bash hook)" ## Properly initialise non-interactive shell
conda activate geoflood-pre

PREPROC='/scratch/04950/dhl/GeoFlood/preprocessing'
python3 "$PREPROC/scripts/geoflood-preprocessing-1m-mp.py" --nhd "$PREPROC/data/NFIEGeo_TX.gdb" --huc12 "$PREPROC/data/WBD_National_GDB/WBD_National_GDB.shp/WBDHU12.shp" --shapefile "$PREPROC/data/TX-UTM14-.6.shp/TX-UTM14-.6.shp" --raster '/scratch/projects/tnris/tnris-lidardata' --availability "$PREPROC/data/TNRIS-LIDAR-Availability-20200219.shp/TNRIS-LIDAR-Availability-20200219.shp" --directory "$PREPROC/data/TX-UTM14-.5-1m-GeoFlood/" --restart "$PREPROC/data/TX-UTM14-.5-1m-GeoFlood/TX-UTM14-.6-1m-GeoFlood.pkl"
PREPROC_WORK='${PREPROC_WORK}'
PREPROC_SCRATCH='/scratch/04950/dhl/GeoFlood-preprocessing'
PREPROC_TNRIS='/scratch/projects/tnris'
python3 "${PREPROC_SCRATCH}/geoflood-preprocessing-1m-mp-utm.py" \
--shapefile "${PREPROC_SCRATCH}/TXDoT-TX_boundary.shp/TXDoT-TX_boundary.shp" \
--huc12 "${PREPROC_WORK}/WBD-HU12-TX.shp/WBD-HU12-TX.shp" \
--nhd "${PREPROC_WORK}/NFIEGeo_TX.gdb" \
--raster "${PREPROC_TNRIS}/tnris-lidardata" \
--availability "${PREPROC_WORK}/TNRIS-LIDAR-Availability-20200219.shp/TNRIS-LIDAR-Availability-20200219.shp" \
--directory "${PREPROC_TNRIS}/dhl-flood-modelling/TX-HUC12-DEM_outputs" \
--restart "${PREPROC_SCRATCH}/geoflood-preprocessing-TX.pickle"

#if [ "x$TACC_RUNTIME" != "x" ]; then
# # there's a runtime limit, so warn the user when the session will die
Expand Down

0 comments on commit 99b23a4

Please sign in to comment.