diff --git a/DEM-HUC12-Availability.png b/DEM-HUC12-Availability.png new file mode 100644 index 0000000..ec15c08 Binary files /dev/null and b/DEM-HUC12-Availability.png differ diff --git a/DEM-HUC12-Outputs_example.jpg b/DEM-HUC12-Outputs_example.jpg new file mode 100644 index 0000000..53e5a70 Binary files /dev/null and b/DEM-HUC12-Outputs_example.jpg differ diff --git a/geoflood-preprocessing-1m-mp.py b/geoflood-preprocessing-1m-mp.py index 6173e69..666a2d0 100644 --- a/geoflood-preprocessing-1m-mp.py +++ b/geoflood-preprocessing-1m-mp.py @@ -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) @@ -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.") diff --git a/geoflood-preprocessing-1m-mp.sh b/geoflood-preprocessing-1m-mp.sh index 028bf5a..07d6fca 100644 --- a/geoflood-preprocessing-1m-mp.sh +++ b/geoflood-preprocessing-1m-mp.sh @@ -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