Skip to content

Commit

Permalink
Create new method to clean up lee-side of linkages
Browse files Browse the repository at this point in the history
Create new method to clean up the “lee-side” of NLCC linkages before calculating Blended Priority. See issue #54.
  • Loading branch information
dkav committed Feb 3, 2019
1 parent 3632cfa commit 4eb27e9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions toolbox/scripts/lp_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,37 @@ def inv_norm(rast_list):
return norm_rast_list


def clip_to_bound_geom(core_lyr, rast_list):
"""Clip NLCC rasters using minimum bounding geometry."""
lm_util.gprint("-Clipping NLCC rasters using minimum bounding geometry")
bnd_rast_list = []
arcpy.env.extent = rast_list[0][1].extent

for fname, bnd_rast in rast_list:
from_core, to_core = fname.split('_')[1:]
xy_lyr = arcpy.MakeFeatureLayer_management(
core_lyr, out_layer="xy_lyr",
where_clause="{} in ({}, {})".format(
lm_env.COREFN, from_core, to_core))

bnd_fc = os.path.join(lm_env.SCRATCHGDB, fname)
if arcpy.CheckProduct("ArcInfo") == "Available":
arcpy.MinimumBoundingGeometry_management(
xy_lyr, bnd_fc, geometry_type="CONVEX_HULL",
group_option="ALL")
else:
arcpy.MinimumBoundingGeometry_management(
xy_lyr, bnd_fc, geometry_type="CIRCLE", group_option="ALL")

bnd_rast = arcpy.sa.ExtractByMask(bnd_rast, bnd_fc)
bnd_rast_list.append([fname, bnd_rast])
lm_util.delete_data(bnd_fc)

arcpy.env.extent = None
save_interm_rast(bnd_rast_list, "bp_step2")
return bnd_rast_list


def clip_nlcc_to_threashold(lcp_lines):
"""Clip NLCC_A_B rasters to CWD threshold.
Expand Down Expand Up @@ -147,6 +178,7 @@ def calc_blended_priority(core_lyr, lcp_lines):
"""Generate Blended Priority raster from NLCC rasters."""
lm_util.gprint("Calculating Blended Priority (BP):")
nlcc_rast = clip_nlcc_to_threashold(lcp_lines)
nlcc_rast = clip_to_bound_geom(core_lyr, nlcc_rast)
nlcc_rast = inv_norm(nlcc_rast)

blended_priority(nlcc_rast, lcp_lines)
Expand Down

0 comments on commit 4eb27e9

Please sign in to comment.