コード例 #1
0
    impermeabilityDifference = 1
lengthDifference = maxOverallLCPLength - minOverallLCPLength
if lengthDifference < 1:
    lengthDifference = 1
pairConnectivityRasterList = []
for pair in pairList:
    paIDA = pair[0]
    paIDB = pair[1]
    lcpLength = pair[2]
    # Invert/Normalize Impermeability based on overall min and max (A - permeability from the wildlife perspective is
    # desirable); cCould develop a new Generic tool or modify existing "Max Score Inverted Normalization from Raster"
    # tool to take an external parm for Max
    impTempRaster = "%scratchWorkspace%\\" + "imp" + paIDA + "-" + paIDB + ".tif"
    prxTempRaster = (maxOverallImpermeability - Raster(impTempRaster)) / impermeabilityDifference
    prmTempRaster = "%scratchWorkspace%\\" + "prm" + paIDA + "-" + paIDB + ".tif"
    arcpy.SetNoDataTo0_laitcp(prxTempRaster, prmTempRaster)
    # Invert/Normalize Corridor Envelope (B - crucial corridors between core areas need to be considered, even if they
    # have low permeability)
    envTempRaster = "%scratchWorkspace%\\" + "env" + paIDA + "-" + paIDB + ".tif"
    nenTempRaster = "%scratchWorkspace%\\" + "nen" + paIDA + "-" + paIDB + ".tif"
    arcpy.MaxScoreInvertedNormalizationFromRaster_laitcp(envTempRaster, studyAreaRasterMask, nenTempRaster)
    # Invert/Normalize LCP Length based on overall min and max (C - shorter corridors are better than longer corridors
    # of the same permeability); then make a constant raster covering Envelope from Normalized LCP Length
    nrmLCPLength = float(maxOverallLCPLength - lcpLength) / float(lengthDifference)
    nleTempRaster = Raster(envTempRaster) - Raster(envTempRaster) + nrmLCPLength
    nllTempRaster = "%scratchWorkspace%\\" + "nll" + paIDA + "-" + paIDB + ".tif"
    arcpy.SetNoDataTo0_laitcp(nleTempRaster, nllTempRaster)
    # Calc Pair Connectivity as Weighted Sum of A, B, C
    pcnTempRaster = (Raster(prmTempRaster) * float(permeabilityWeight)) +\
                    (Raster(nenTempRaster) * float(corridorEnvelopeWeight)) +\
                    (Raster(nllTempRaster) * float(lcpLengthWeight))
コード例 #2
0
    # Select unique road class threat value...
    WhereClause = " \"ROADS_THT\" > " + str(
        RoadThreat - 0.000001) + " AND \"ROADS_THT\" < " + str(RoadThreat +
                                                               0.000001)
    arcpy.SelectLayerByAttribute_management("RoadsLYR", "NEW_SELECTION",
                                            WhereClause)

    # Select parcel polygons adjacent to road threat line features ...
    arcpy.SelectLayerByLocation_management("PropertiesLYR",
                                           "WITHIN_A_DISTANCE", "RoadsLYR",
                                           AdjacencyTolerance + " Meters",
                                           "NEW_SELECTION")

    # CalculateField to hold the current road threat value
    arcpy.CalculateField_management("PropertiesLYR", "ROAD_ADJ_THT",
                                    "\"" + str(RoadThreat) + "\"",
                                    "PYTHON_9.3", "")

# Convert road adjacency threat to raster
arcpy.AddMessage(
    "Converting Road Adjacency Threat to raster and reclassifying NoData to 0")
TempRaster = "%scratchWorkspace%\\temprpt.tif"
arcpy.FeatureToRaster_conversion(PropertiesFeatureClass, "ROAD_ADJ_THT",
                                 TempRaster)

# Reclass NoData to 0 (if a Mask is set, this happens within Mask and all other values are set to NoData)...
arcpy.SetNoDataTo0_laitcp(TempRaster, RoadAdjacencyThreatOutputRaster)

# Delete temp datasets
arcpy.Delete_management(TempRaster)
コード例 #3
0
    for TEM_SEMRow in TEM_SEMCursor:
        # Local Vars...
        DEC1 = TEM_SEMRow[0]/100
        DEC2 = TEM_SEMRow[1]/100
        DEC3 = TEM_SEMRow[2]/100
        ATRISK_IMP1 = TEM_SEMRow[3]
        ATRISK_IMP2 = TEM_SEMRow[4]
        ATRISK_IMP3 = TEM_SEMRow[5]
        # Calc...
        ATRISK_IMP = 0.0
        if ATRISK_IMP1 is not None:
            ATRISK_IMP = ATRISK_IMP + (DEC1 * ATRISK_IMP1)
        if ATRISK_IMP2 is not None:
            ATRISK_IMP = ATRISK_IMP + (DEC2 * ATRISK_IMP2)
        if ATRISK_IMP3 is not None:
            ATRISK_IMP = ATRISK_IMP + (DEC3 * ATRISK_IMP3)
        TEM_SEMRow[6] = ATRISK_IMP
        # Update
        TEM_SEMCursor.updateRow(TEM_SEMRow)
del TEM_SEMCursor, TEM_SEMRow

# Convert the polygon to raster based on the ECO_SEN field...
TempRaster = "%scratchWorkspace%\\temprst0050.tif"
arcpy.FeatureToRaster_conversion(TEM_SEM, "ATRISK_IMP", TempRaster)

# Reclass NoData to 0 (if a Mask is set, this happens within Mask and all other values are set to NoData)...
arcpy.SetNoDataTo0_laitcp(TempRaster, OutputRaster)

# Delete temp datasets...
arcpy.Delete_management(TempRaster)
コード例 #4
0
    arcpy.AddField_management(TempFeatureClass, "MCL_PERC", "FLOAT")

    # For each of the unique mapclasses calculate Decile value for each of the three possible ecosystem levels into the
    # newly created field...
    if int(arcpy.GetCount_management(TempFeatureClass).getOutput(0)) > 0:
        with arcpy.da.UpdateCursor(TempFeatureClass, ["MCL1", "MCL2", "MCL3", "DEC1", "DEC2","DEC3",
                                                      "MCL_PERC"]) as OutputCursor:
            for OutputRow in OutputCursor:
                # Accumulate the percentages across the 3 original values...
                perc = 0.0
                if OutputRow[0] == MapClass:
                    perc = perc + (OutputRow[3] / 100.0)
                if OutputRow[1] == MapClass:
                    perc = perc + (OutputRow[4] / 100.0)
                if OutputRow[2] == MapClass:
                    perc = perc + (OutputRow[5] / 100.0)
                OutputRow[6] = perc
                OutputCursor.updateRow(OutputRow)
        del OutputCursor, OutputRow

        # Convert the polygon to raster based on the MCL_PERC field...
        TempRaster = "%scratchWorkspace%\\temprst0030.tif"
        arcpy.FeatureToRaster_conversion(TempFeatureClass, "MCL_PERC", TempRaster)

        # Reclass NoData to 0 (if a Mask is set, this happens within Mask and all other values are set to NoData)...
        arcpy.SetNoDataTo0_laitcp(TempRaster, "%workspace%\\" + MapClass + ".tif")

        # Delete temp datasets...
        arcpy.Delete_management(TempFeatureClass)
        arcpy.Delete_management(TempRaster)
コード例 #5
0
toolboxpath = scriptdir + "\\..\\toolbox\\LandAdvisor-ITCP.tbx"
arcpy.AddToolbox(toolboxpath)

# Check out any necessary licenses...
arcpy.CheckOutExtension("spatial")

# Script Arguments...
ProtectedAreasFeatureClass = sys.argv[1]
IUCNImportanceTable = sys.argv[2]
IUCNClassificationOutputRaster = sys.argv[3]

# Add and calculate field
arcpy.AddField_management(ProtectedAreasFeatureClass, "IUCN_IMP", "float")
arcpy.MakeFeatureLayer_management(ProtectedAreasFeatureClass,
                                  "PROTECTED_AREAS_LYR")
arcpy.AddJoin_management("PROTECTED_AREAS_LYR", "IUCN_DES",
                         IUCNImportanceTable, "IUCNDesignation", "KEEP_ALL")
arcpy.CalculateField_management("PROTECTED_AREAS_LYR", "IUCN_IMP",
                                "!IUCNImportance$.Importance!", "PYTHON_9.3",
                                "")
arcpy.RemoveJoin_management("PROTECTED_AREAS_LYR", "IUCNImportance$")

# Convert to rastert and set NoData to 0
TempRaster = "%scratchWorkspace%\\temprst0021.tif"
arcpy.FeatureToRaster_conversion(ProtectedAreasFeatureClass, "IUCN_IMP",
                                 TempRaster)
arcpy.SetNoDataTo0_laitcp(TempRaster, IUCNClassificationOutputRaster)

# Delete temp datasets...
arcpy.Delete_management(TempRaster)
コード例 #6
0
studyAreaRasterMask = sys.argv[7]
smallestProtectedArea = sys.argv[8]
maxProtectedAreaSeparation = sys.argv[9]
protectedAreaPairsOutputFeatureClass = sys.argv[10]
deleteTemps = sys.argv[11]

# Generate Cost Surface from Composition, Road Threat, and Stream Benefit
arcpy.AddMessage("Started Generating Cost Surface at: " + time.ctime())
# Invert Composition
costTempRaster1 = 1.0 - Raster(compositionRaster)
# Convert Roads Threat to Raster
roadsThreatTempRaster1 = "%scratchWorkspace%\\rdtht1.tif"
arcpy.FeatureToRaster_conversion(roadsFeatureClass, "ROADS_THT",
                                 roadsThreatTempRaster1)
roadsThreatTempRaster2 = "%scratchWorkspace%\\rdtht2.tif"
arcpy.SetNoDataTo0_laitcp(roadsThreatTempRaster1, roadsThreatTempRaster2)
# Convert Streams to Raster, inverting benefit to get cost
arcpy.AddField_management(streamsFeatureClass, "Cost", "FLOAT")
streamCost = 1 / float(streamBenefitFactor)
arcpy.CalculateField_management(streamsFeatureClass, "Cost", str(streamCost),
                                "PYTHON_9.3", "")
streamsTempRaster1 = "%scratchWorkspace%\\strms1.tif"
arcpy.FeatureToRaster_conversion(streamsFeatureClass, "Cost",
                                 streamsTempRaster1)
streamsTempRaster2 = "%scratchWorkspace%\\strms2.tif"
arcpy.SetNoDataToValue_laitcp(streamsTempRaster1, streamsTempRaster2, "1")
# Add Roads and Streams to Cost Surface, assigning Roads a very high cost
costTempRaster2 = Raster(streamsTempRaster2) * (
    costTempRaster1 +
    (float(roadThreatMultiplier) * Raster(roadsThreatTempRaster2)))
costTempRaster2.save("%scratchWorkspace%\\costrst.tif")