currently, there is the lp_settings.py option to normalize using score range or max value.
Relative closeness and size normalizations could benefit greatly from an inverse exponential, or even a "histogram equalize" option, so that very short linkages are not off the charts compared to regular length and long linkages.
Rather than the following values be in linear:
4, 9, 16, 25, 36...
2,3,4,5,6...
Cherry on top is to define the exponent as the second paramater. (in this case it is 0.5)
Looks fairly straightforward.
In the below script, add
NM_SQR = "Square Root" # Square Root Normalization
and add an elif (else if) and the function?
if normalization_method == NM_SCORE:
if invert:
return (max_val - in_raster) / (max_val - min_val)
return (in_raster - min_val) / (max_val - min_val)
elif normalization_method == NM_SQR:
outSQRT = SquareRoot(in_raster)
{Code needs to here to get the new_max_val and new_min_val raster after the square root, and that are needed for the next step (normalizing linearly to 0-1)}
if invert:
return (new_max_val - outSQRT) / (new_max_val - new_min_val)
return (outSQRT - new_min_val) / (new_max_val - new_min_val)
# double check the math logic of the above and that if inverting you sholdn't square it first...
else: # Max score normalization
if invert:
return (max_val + min_val - in_raster) / max_val
XXXXXXXXXXXXXXXXXXXX
_SCRIPT_NAME = "lp_main.py"
NM_SCORE = "SCORE_RANGE" # Score range normalization
NM_MAX = "MAX_VALUE" # Maximum value normalization
CoordPoint = namedtuple('Point', 'x y')
class AppError(Exception):
"""Custom error class."""
def normalize_raster(in_raster, normalization_method=NM_MAX, invert=False):
"""Normalize values in in_raster.
Normalize values in in_raster using score range or max score method,
with optional inversion.
"""
lm_util.build_stats(in_raster)
result = arcpy.GetRasterProperties_management(in_raster, "MINIMUM")
min_val = float(result.getOutput(0))
result = arcpy.GetRasterProperties_management(in_raster, "MAXIMUM")
max_val = float(result.getOutput(0))
if max_val > 0:
if normalization_method == NM_SCORE:
if invert:
return (max_val - in_raster) / (max_val - min_val)
return (in_raster - min_val) / (max_val - min_val)
else: # Max score normalization
if invert:
return (max_val + min_val - in_raster) / max_val
return in_raster / max_val
else:
return in_raster * 0
currently, there is the lp_settings.py option to normalize using score range or max value.
Relative closeness and size normalizations could benefit greatly from an inverse exponential, or even a "histogram equalize" option, so that very short linkages are not off the charts compared to regular length and long linkages.
Rather than the following values be in linear:
4, 9, 16, 25, 36...
2,3,4,5,6...
Cherry on top is to define the exponent as the second paramater. (in this case it is 0.5)
Looks fairly straightforward.
In the below script, add
NM_SQR = "Square Root" # Square Root Normalization
and add an elif (else if) and the function?
{Code needs to here to get the new_max_val and new_min_val raster after the square root, and that are needed for the next step (normalizing linearly to 0-1)}
XXXXXXXXXXXXXXXXXXXX
_SCRIPT_NAME = "lp_main.py"
NM_SCORE = "SCORE_RANGE" # Score range normalization
NM_MAX = "MAX_VALUE" # Maximum value normalization
CoordPoint = namedtuple('Point', 'x y')
class AppError(Exception):
"""Custom error class."""
def normalize_raster(in_raster, normalization_method=NM_MAX, invert=False):
"""Normalize values in in_raster.