def updateMessages(self): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" import LUCI_SEEA.lib.input_validation as input_validation refresh_modules(input_validation) input_validation.checkFilePaths(self)
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_RUSLE_scen_acc as t_RUSLE_scen_acc refresh_modules(t_RUSLE_scen_acc) t_RUSLE_scen_acc.function(parameters)
from arcpy.sa import FlowAccumulation, FlowDirection, ApplyEnvironment, Sink, SnapPourPoint, SetNull, StreamOrder, Slope import os import traceback import stat import math import configuration import sys import LUCI_SEEA.lib.progress as progress import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common import LUCI_SEEA.solo.reconditionDEM as reconditionDEM import LUCI_SEEA.lib.baseline as baseline from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common, reconditionDEM, baseline]) def function(outputFolder, DEM, studyAreaMask, streamInput, minAccThresh, majAccThresh, smoothDropBuffer, smoothDrop, streamDrop, reconDEM, rerun=False): try:
import arcpy import os import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common import LUCI_SEEA.lib.progress as progress import LUCI_SEEA.solo.calc_zonal as CalcZonal from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common, CalcZonal]) def function(params): try: pText = common.paramsAsText(params) # Get inputs runSystemChecks = common.strToBool(pText[1]) outputFolder = pText[2] inputRaster = pText[5] aggregationZones = pText[6] aggregationColumn = pText[7] rerun = False # Create output folder if not os.path.exists(outputFolder): os.mkdir(outputFolder)
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_RUSLE_accounts as t_RUSLE_accounts refresh_modules(t_RUSLE_accounts) t_RUSLE_accounts.function(parameters)
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_PAspeciesRichness as t_PAspeciesRichness refresh_modules(t_PAspeciesRichness) t_PAspeciesRichness.function(parameters)
import arcpy from arcpy.sa import Reclassify, RemapRange import os import sys import shutil import datetime # For writing current date/time to inputs.xml import time # For logging warnings that are very close together import xml.etree.cElementTree as ET from LUCI_SEEA.lib.external import six # Python 2/3 compatibility module import configuration import LUCI_SEEA.lib.log as log from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log]) def addlayer(doc, dataSource, symbologyLayerFile, trans_ratio, groupLayerName, visible=True, layerName='', suffix=''): # trans_ratio is transparency ratio, 0 = no transparancy # symbologyLayerFile is layer containing symbology for newly generated dataSource # dataSource is layer generated by LUCI try:
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_calc_extent as t_calc_extent refresh_modules(t_calc_extent) t_calc_extent.function(parameters)
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_change_user_settings as t_change_user_settings refresh_modules(t_change_user_settings) t_change_user_settings.function(parameters)
import arcpy import os import configuration import LUCI_SEEA.lib.common as common from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules(common) class ChangeUserSettings(object): class ToolValidator: """Class for validating a tool's parameter values and controlling the behavior of the tool's dialog.""" def __init__(self, parameters): """Setup the Geoprocessor and the list of tool parameters.""" self.params = parameters def initializeParameters(self): """Refine the properties of a tool's parameters. This method is called when the tool is opened.""" return def updateParameters(self): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parameter has been changed.""" # Set defaults or override them from user settings file (if the values exist in the file) userSettings = configuration.userSettingsFile try: if os.path.exists(userSettings):
import arcpy import os import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common import LUCI_SEEA.solo.RUSLE_accounts as RUSLE_accounts from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common, RUSLE_accounts]) def function(params): try: pText = common.paramsAsText(params) # Get inputs runSystemChecks = common.strToBool(pText[1]) outputFolder = pText[5] yearAFolder = pText[6] yearBFolder = pText[7] # Inputs constant between the two years slopeOption = pText[8] slopeAngle = pText[9] rData = pText[10] soilData = pText[11] soilCode = pText[12] # Land covers YearALCData = pText[13]
import arcpy import os import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common import LUCI_SEEA.solo.PAspeciesRichness as PAspeciesRichness from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common, PAspeciesRichness]) def function(params): try: pText = common.paramsAsText(params) runSystemChecks = common.strToBool(pText[1]) # Get inputs if params[2].name == 'Output_folder': outputFolder = pText[2] elif params[2].name == 'Species_richness': outputFolder = os.path.join(arcpy.env.scratchFolder, 'Species_richness') speciesRichness = pText[2] IUCN_rl_data = pText[4] studymask = pText[5] speciesdisplayname = pText[6] #aggregateMask = pText[7] # will add optional mask if want to calculate over aggregrate spatial units
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_RUSLE as t_RUSLE refresh_modules(t_RUSLE) t_RUSLE.function(parameters)
import arcpy import os import sys import LUCI_SEEA.lib.polygon_tools as polygon_tools from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules(polygon_tools) def function(inputExtent, outGrid, cellSize, proportionCellArea, gridCoverage, gridBoundaryCellsPercent, bufferLength, align, sigFigs): ''' By Shaun Astbury ([email protected]) and B Jackson and Keith Miller Python script created to utilise the polygon tools module. Generates a grid of square-shaped cells of a specified size, from an input polygon extent. The grid extent can optionally be aligned to suitable coordinates e.g. 123456 to 123000, and have a buffer applied. If a desired cell size is not known, set to zero. The output grid will overlap the input extent completely, and as such, if the extent is not exactly divisible by the chosen cell size, the extent of the output will be slightly larger than that of the input. ''' try: # Set the temporary variables prefix = "grid_" baseTempName = os.path.join(arcpy.env.scratchGDB, prefix) intersection = baseTempName + "intersection" gridMinusIntersection = baseTempName + "gridMinusIntersection"
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_aggregate_data as t_aggregate_data refresh_modules(t_aggregate_data) t_aggregate_data.function(parameters)
import arcpy import os import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common import LUCI_SEEA.solo.RUSLE_scen_acc as RUSLE_scen_acc from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common, RUSLE_scen_acc]) def function(params): try: pText = common.paramsAsText(params) # Get inputs runSystemChecks = common.strToBool(pText[1]) outputFolder = pText[5] yearAFolder = pText[6] yearBFolder = pText[7] slopeOption = pText[8] slopeAngle = pText[9] yearARain = pText[10] yearBRain = pText[11] yearASupport = pText[12] yearBSupport = pText[13] # Set option for LS-factor if slopeOption == 'Calculate based on slope and length only': lsOption = 'SlopeLength'
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_creategrid as t_creategrid refresh_modules(t_creategrid) t_creategrid.function(parameters)
''' Change user settings tool ''' import arcpy import os import configuration import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common]) def function(params): common.runSystemChecks( ) # Run to ensure config.xml is copied across to user_settings.xml if needed. This line can be removed after 31/10/18. # Get inputs p = common.paramsAsText(params) scratchPath = p[1] developerMode = common.strToBool(p[2]) if developerMode == True: developerMode = 'Yes' else: developerMode = 'No' # Override the default values from user settings file (if they exist in the file)
import arcpy import os import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common import LUCI_SEEA.lib.aggregate_data as aggregate_data from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common, aggregate_data]) def function(params): class DataToAggregate: def __init__(self, dataSet, linkCode): self.dataSet = dataSet self.linkCode = linkCode try: pText = common.paramsAsText(params) # Get inputs if params[2].name == 'Output_folder': outputFolder = pText[2] elif params[2].name == 'Aggregated_data': outputFolder = os.path.join(arcpy.env.scratchFolder, 'AggregatedData') aggregatedData = pText[2] runSystemChecks = common.strToBool(pText[1]) dataToAggregate = pText[7] classificationColumn = pText[8]
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_preprocess_dem as t_preprocess_dem refresh_modules(t_preprocess_dem) t_preprocess_dem.function(parameters)
import arcpy import os import sys import traceback import configuration import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.progress as progress import LUCI_SEEA.lib.common as common import LUCI_SEEA.lib.baseline as baseline import LUCI_SEEA.solo.preprocess_dem as preprocess_dem from LUCI_SEEA.lib.refresh_modules import refresh_modules from LUCI_SEEA.lib.external import six # Python 2/3 compatibility module refresh_modules([log, common, baseline, preprocess_dem]) def function(params): try: ################### ### Read inputs ### ################### pText = common.paramsAsText(params) outputFolder = pText[1] inputDEM = common.fullPath(pText[2]) inputStudyAreaMask = pText[3] inputLC = pText[4]
LUCI RUSLE accounts function ''' import sys import os import configuration import numpy as np import arcpy from arcpy.sa import * import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common from LUCI_SEEA.lib.external import six # Python 2/3 compatibility module import LUCI_SEEA.solo.RUSLE as RUSLE from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common, RUSLE]) def function(outputFolder, yearAFolder, yearBFolder, lsOption, slopeAngle, rData, soilData, soilCode, YearALCData, YearALCCode, YearBLCData, YearBLCCode, YearAPData, YearBPData, saveFactors): try: # Set temporary variables prefix = os.path.join(arcpy.env.scratchGDB, "rusleAcc_") clipA = prefix + "clipA" clipB = prefix + "clipB" lossA = prefix + "lossA" lossB = prefix + "lossB" diffLoss = prefix + "diffLoss"
def execute(self, parameters, messages): import LUCI_SEEA.tools.t_calc_zonal as t_calc_zonal refresh_modules(t_calc_zonal) t_calc_zonal.function(parameters)
import arcpy import os import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common import LUCI_SEEA.lib.progress as progress import LUCI_SEEA.solo.calc_extent as CalcExtent from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common, CalcExtent]) def function(params): try: pText = common.paramsAsText(params) # Get inputs runSystemChecks = common.strToBool(pText[1]) outputFolder = pText[2] inputData = pText[4] aggregationColumn = pText[5] rerun = False # Create output folder if not os.path.exists(outputFolder): os.mkdir(outputFolder) # System checks and setup if runSystemChecks:
import arcpy import os import LUCI_SEEA.lib.log as log import LUCI_SEEA.lib.common as common import LUCI_SEEA.solo.land_accounts as land_accounts from LUCI_SEEA.lib.refresh_modules import refresh_modules refresh_modules([log, common, land_accounts]) def function(params): try: pText = common.paramsAsText(params) runSystemChecks = common.strToBool(pText[1]) if params[2].name == 'Output_folder': outputFolder = pText[2] elif params[2].name == 'Land_extent_accounts': outputFolder = os.path.join(arcpy.env.scratchFolder, 'LCaccounts') LCaccounts = pText[2] lcOption = pText[3] inputLC = pText[4] openingLC = pText[5] closingLC = pText[6] openingField = pText[7] closingField = pText[8]