Skip to content

Commit

Permalink
added hillshade to rcat
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgilbert authored and MattReimer committed Aug 24, 2023
1 parent 190a716 commit bd63b83
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/commons/rscommons/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.4.5"
__version__ = "1.4.6"
2 changes: 1 addition & 1 deletion packages/anthro/anthro/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.4"
__version__ = "0.2.0"
2 changes: 1 addition & 1 deletion packages/anthro/anthro/anthro.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from rscommons import Logger, initGDALOGRErrors, RSLayer, RSProject, ModelConfig, dotenv
from rscommons.database import create_database, SQLiteCon
from rscommons.copy_features import copy_features_fields
from rscommons.moving_window import get_moving_windows, moving_window_dgo_ids
from rscommons.moving_window import moving_window_dgo_ids
from rscommons.augment_lyr_meta import augment_layermeta, add_layer_descriptions, raster_resolution_meta

from anthro.utils.conflict_attributes import conflict_attributes
Expand Down
3 changes: 2 additions & 1 deletion packages/anthro/anthro/utils/igo_vegetation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def igo_vegetation(windows: dict, landuse_raster: str, out_gpkg_path: str):
for dgo_ftr, *_ in dgo_lyr.iterate_features():
dgoid = dgo_ftr.GetFID()
dgo_ogr = dgo_ftr.GetGeometryRef()
dgo_geom = VectorBase.ogr2shapely(dgo_ogr)
dgo_g = VectorBase.ogr2shapely(dgo_ogr)
dgo_geom = dgo_g.buffer(geo_transform[1] / 2) # buffer by raster resolution to ensure we get all cells
try:
raw_raster = mask(src, [dgo_geom], crop=True)[0]
mask_raster = np.ma.masked_values(raw_raster, src.nodata)
Expand Down
9 changes: 1 addition & 8 deletions packages/anthro/database/anthro_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ CREATE TABLE IGOAttributes (
LevelPathI REAL,
seg_distance REAL,
stream_size INTEGER,
window_area REAL,
window_length REAL,
LUI REAL,
Road_len REAL,
Road_dens REAL,
Expand All @@ -83,15 +81,10 @@ CREATE TABLE DGOAttributes (
segment_area REAL,
LUI REAL,
Road_len REAL,
Road_dens REAL,
Rail_len REAL,
Rail_dens REAL,
Canal_len REAL,
Canal_dens REAL,
RoadX_ct INTEGER,
RoadX_dens REAL,
DivPts_ct INTEGER,
DivPts_dens REAL);
DivPts_ct INTEGER);

CREATE TABLE ReachAttributes (
ReachID INTEGER PRIMARY KEY NOT NULL,
Expand Down
1 change: 1 addition & 0 deletions packages/rcat/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"${input:HUC}",
"{env:DATA_ROOT}/rs_context/${input:HUC}/vegetation/existing_veg.tif",
"{env:DATA_ROOT}/rs_context/${input:HUC}/vegetation/historic_veg.tif",
"{env:DATA_ROOT}/rs_context/${input:HUC}/topography/dem_hillshade.tif",
"{env:DATA_ROOT}/taudem/${input:HUC}/intermediates/pitfill.tif",
"{env:DATA_ROOT}/anthro/${input:HUC}/outputs/anthro.gpkg/vwIgos",
"{env:DATA_ROOT}/anthro/${input:HUC}/outputs/anthro.gpkg/vwDgos",
Expand Down
2 changes: 1 addition & 1 deletion packages/rcat/rcat/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.6"
__version__ = "3.1.0"
9 changes: 6 additions & 3 deletions packages/rcat/rcat/rcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

LYR_DESCRIPTIONS_JSON = os.path.join(os.path.dirname(__file__), 'layer_descriptions.json')
LayerTypes = {
'HILLSHADE': RSLayer('Hillshade', 'HILLSHADE', 'Raster', 'inputs/hillshade.tif'),
'EXVEG': RSLayer('Existing Vegetation', 'EXVEG', 'Raster', 'inputs/existing_veg.tif'),
'HISTVEG': RSLayer('Historic Vegetation', 'HISTVEG', 'Raster', 'inputs/historic_veg.tif'),
'EXRIPARIAN': RSLayer('Existing Riparian', 'EXRIPARIAN', 'Raster', 'intermediates/ex_riparian.tif'),
Expand Down Expand Up @@ -79,7 +80,7 @@
}


def rcat(huc: int, existing_veg: Path, historic_veg: Path, pitfilled: Path, igo: Path, dgo: Path,
def rcat(huc: int, existing_veg: Path, historic_veg: Path, hillshade: Path, pitfilled: Path, igo: Path, dgo: Path,
reaches: Path, roads: Path, rails: Path, canals: Path, valley: Path, output_folder: Path,
flow_areas: Path, waterbodies: Path, meta: Dict[str, str]):

Expand All @@ -104,6 +105,7 @@ def rcat(huc: int, existing_veg: Path, historic_veg: Path, pitfilled: Path, igo:
log.info('Adding input rasters to project')
_prj_existing_path_node, prj_existing_path = project.add_project_raster(proj_nodes['Inputs'], LayerTypes['EXVEG'], existing_veg)
_prj_historic_path_node, prj_historic_path = project.add_project_raster(proj_nodes['Inputs'], LayerTypes['HISTVEG'], historic_veg)
project.add_project_raster(proj_nodes['Inputs'], LayerTypes['HILLSHADE'], hillshade)
project.add_project_raster(proj_nodes['Inputs'], LayerTypes['PITFILL'], pitfilled)

project.add_project_geopackage(proj_nodes['Inputs'], LayerTypes['INPUTS'])
Expand Down Expand Up @@ -381,6 +383,7 @@ def main():
parser.add_argument('huc', help='HUC identifier', type=str)
parser.add_argument('existing_veg', help='National existing vegetation raster', type=str)
parser.add_argument('historic_veg', help='National historic vegetation raster', type=str)
parser.add_argument('hillshade', help='Hillshade raster', type=str)
parser.add_argument('pitfilled', help='Pit filled DEM raster', type=str)
parser.add_argument('igo', help='Integrated geographic object with anthro attributes', type=str)
parser.add_argument('dgo', help='Discrete geographic objects', type=str)
Expand Down Expand Up @@ -410,14 +413,14 @@ def main():
from rscommons.debug import ThreadRun
memfile = os.path.join(args.output_dir, 'rcat_mem.log')
retcode, max_obj = ThreadRun(rcat, memfile, args.huc,
args.existing_veg, args.historic_veg, args.pitfilled, args.igo,
args.existing_veg, args.historic_veg, args.hillshade, args.pitfilled, args.igo,
args.dgo, args.reaches, args.roads, args.rails, args.canals,
args.valley, args.output_folder, args.flow_areas, args.waterbodies,
meta=meta)
log.debug(f'Return code: {retcode}, [Max process usage] {max_obj}')

else:
rcat(args.huc, args.existing_veg, args.historic_veg, args.pitfilled, args.igo, args.dgo,
rcat(args.huc, args.existing_veg, args.historic_veg, args.hillshade, args.pitfilled, args.igo, args.dgo,
args.reaches, args.roads, args.rails, args.canals, args.valley, args.output_folder, args.flow_areas,
args.waterbodies, meta=meta)

Expand Down
3 changes: 2 additions & 1 deletion scripts/automation/FargateRCAT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ cd /usr/local/src
# Get the RSCli project we need to make this happen
rscli download $RSCONTEXT_DIR --id $RSCONTEXT_ID \
--file-filter "(vegetation|nhdplushr.gpkg|project_bounds.geojson)" \
--file-filter "(vegetation|nhdplushr.gpkg|dem_hillshade.tif|project_bounds.geojson)" \
--no-input --no-ui --verbose
# Go get vbet result for this to work
Expand Down Expand Up @@ -110,6 +110,7 @@ try() {
rcat $HUC \
$RSCONTEXT_DIR/vegetation/existing_veg.tif \
$RSCONTEXT_DIR/vegetation/historic_veg.tif \
$RSCONTEXT_DIR/topography/dem_hillshade.tif \
$TAUDEM_DIR/intermediates/pitfill.tif \
$ANTHRO_DIR/outputs/anthro.gpkg/vwIgos \
$ANTHRO_DIR/inputs/inputs.gpkg/dgo \
Expand Down

0 comments on commit bd63b83

Please sign in to comment.