def __init__(self, root_dir, resources_dir): self.in_aoi = arcpy.GetParameter(0) self.in_extent = arcpy.GetParameter(1) self.in_map_type = arcpy.GetParameter(2) self.warning_statements = [] self.root_dir = root_dir self.resources_dir = resources_dir self.original_root_dir = root_dir self.output_dir = arcpy.env.scratchWorkspace self.cur_time = '{0:%Y%m%d_%H%M%S}'.format(datetime.datetime.now()) self.cur_date = '{0:%Y%m%d}'.format(datetime.datetime.now()) self.execution_percentage = 0 self.page_cnt = 0 self.token = None # look at root directory and import the config try: self.report_folder_name = re.split(r'/|\\', self.root_dir)[-1] with open(os.sep.join([self.resources_dir, 'config.json'])) as f: self.config = json.load(f) except FileNotFoundError: sys.exit()
def GetArgs(): lookup_table = arcpy.GetParameterAsText(0) aoi_raster = arcpy.GetParameterAsText(1) dataset_dir = arcpy.GetParameterAsText(2) yield_function = arcpy.GetParameterAsText(3) percentile_column = arcpy.GetParameterAsText(4) fertilizer_dir = arcpy.GetParameterAsText(5) irrigation_raster = arcpy.GetParameterAsText(6) compute_nutritional_contents = arcpy.GetParameter(7) nutrient_table = arcpy.GetParameterAsText(8) compute_financial_analysis = arcpy.GetParameter(9) economics_table = arcpy.GetParameterAsText(10) outList_tabs = [] try: args = { u'lookup_table': lookup_table, u'aoi_raster': aoi_raster, u'dataset_dir': dataset_dir, u'yield_function': yield_function, u'compute_financial_analysis': False, u'compute_nutritional_contents': False, u'workspace_dir': workspace_dir, u'results_suffix': u'', } if fertilizer_dir and fertilizer_dir != "#": args[u'fertilizer_dir'] = fertilizer_dir if yield_function == 'percentile': args[u'percentile_column'] = percentile_column if yield_function == 'regression': if not fertilizer_dir or fertilizer_dir == "#": arcpy.AddError( "A fertilizer raster folder is required when choosing regression as 'Yield Function'!" ) raise SystemExit() args[u'irrigation_raster'] = irrigation_raster if compute_financial_analysis: args[u'compute_financial_analysis'] = True args[u'economics_table'] = economics_table out_economic_tab = os.path.join( arcpy.env.scratchFolder, _OUTPUT['financial_analysis_table']) outList_tabs.append(out_economic_tab) if compute_nutritional_contents: args[u'compute_nutritional_contents'] = True args[u'nutrient_table'] = nutrient_table out_nutr_tab = os.path.join(arcpy.env.scratchFolder, _OUTPUT['nutrient_contents_table']) outList_tabs.append(out_nutr_tab) except Exception: e = sys.exc_info()[1] arcpy.AddError('An error occurred: {}'.format(e.args[0])) return args, outList_tabs
def main(argv=None): # Input map in the current project in_map = arcpy.GetParameterAsText(0) arcpy.AddMessage("# Input map : {0}.".format(in_map)) # Specify the area where the delta new part vtpk need to be created AOI = arcpy.GetParameterAsText(1) arcpy.AddMessage("# AOI : {0}.".format(AOI)) # Choose the existing original adv vtpk origin_vtpk = arcpy.GetParameterAsText(2) arcpy.AddMessage("# Original vtpk : {0}.".format(origin_vtpk)) # Update 2018-9-20 add boolean parameter to check if the vtpk is advanced # Check if the vtpk is advanced is_adv_vtpk = arcpy.GetParameter(3) arcpy.AddMessage("# Is Advanced Vtpk : {0}.".format(is_adv_vtpk)) # Specify the index polygon index_polygon = arcpy.GetParameter(4) arcpy.AddMessage("# Index Polygon path : {0}.".format(index_polygon)) # Specify name and workspace for new part vtpk out_part_vtpk = arcpy.GetParameterAsText(5) arcpy.AddMessage("# New part vtpk : {0}.".format(out_part_vtpk)) execute(in_map, AOI, origin_vtpk, is_adv_vtpk, index_polygon, out_part_vtpk)
def main(): arcrestZip = 'arcrest.zip' arcrestHelperZip = 'arcresthelper.zip' get_latest = arcpy.GetParameter(0) installInBoth = arcpy.GetParameter(1) base_folder = os.path.dirname(__file__) #arcpy.AddMessage("%s: " % base_folder) base_folder = os.path.dirname(base_folder) #arcpy.AddMessage("%s: " % base_folder) base_folder = os.path.dirname(base_folder) #arcpy.AddMessage("%s: " % base_folder) base_file = os.path.splitext(os.path.basename(__file__))[0] if get_latest: arcrest_zip, arcresthelper_zip = download_arcrest() else: commondata = os.path.join(base_folder, "commondata") if os.path.isdir(os.path.join(commondata, base_file)): arcrest_zip = os.path.join(commondata, base_file, arcrestZip) arcresthelper_zip = os.path.join(commondata, base_file, arcrestHelperZip) elif os.path.isdir(os.path.join(commondata, "userdata")): arcrest_zip = os.path.join(commondata, "userdata", arcrestZip) arcresthelper_zip = os.path.join(commondata, "userdata", arcrestHelperZip) site_package = None site_package64 = None defPath = os.path.dirname(os.__file__) if ('ArcGIS' in defPath): if ('x64' in defPath): site_package = os.path.join(defPath.replace('x64', ''), 'site-packages') site_package64 = os.path.join(defPath, 'site-packages') else: site_package = os.path.join(defPath, 'site-packages') site_package64 = os.path.join( defPath.replace('ArcGIS', 'ArcGISx64'), 'site-packages') else: site_package = os.path.join(defPath, 'site-packages') ## for p in sys.path: ## if p.lower().find("site-packages") > -1: ## site_package = p ## break ## del p if site_package is None: raise arcpy.ExecuteError("Could not find the site-package folder") installPackages(arcrest_zip, arcresthelper_zip, site_package) if site_package64 is not None and installInBoth == True: arcpy.AddMessage(" ") arcpy.AddMessage("-----------------------------------------------") arcpy.AddMessage(" ") installPackages(arcrest_zip, arcresthelper_zip, site_package64) arcpy.AddMessage(" ") arcpy.AddMessage("... Process Complete ...".format(site_package))
def execute(): in_map = arcpy.GetParameter(0) arcpy.AddMessage("Input map : {0}.".format(in_map)) in_layers = arcpy.GetParameter(1) field_name = "lod" CalculateLods.calculate_lods_for_feature(in_layers, field_name)
def setupKFunction(): """Retrieves the parameters from the User Interface and executes the appropriate commands.""" inputFC = ARCPY.GetParameterAsText(0) outputTable = ARCPY.GetParameterAsText(1) nIncrements = ARCPY.GetParameter(2) permutations = ARCPY.GetParameterAsText(3).upper().replace(" ", "_") displayIt = ARCPY.GetParameter(4) weightField = UTILS.getTextParameter(5, fieldName = True) begDist = UTILS.getNumericParameter(6) dIncrement = UTILS.getNumericParameter(7) edgeCorrection = ARCPY.GetParameterAsText(8).upper().replace(" ", "_") studyAreaMethod = ARCPY.GetParameterAsText(9).upper().replace(" ", "_") studyAreaFC = UTILS.getTextParameter(10) #### Resolve Table Extension #### if ".dbf" not in OS.path.basename(outputTable): dirInfo = ARCPY.Describe(OS.path.dirname(outputTable)) if dirInfo == "FileSystem": outputTable = outputTable + ".dbf" #### Resolve Remaining Parameters #### if nIncrements > 100: nIncrements = 100 if edgeCorrection == "NONE" or edgeCorrection == "#": edgeCorrection = None elif edgeCorrection == "SIMULATE_OUTER_BOUNDARY_VALUES": edgeCorrection = "Simulate" elif edgeCorrection == "REDUCE_ANALYSIS_AREA": edgeCorrection = "Reduce" else: edgeCorrection = "Ripley" if permutations == "0_PERMUTATIONS_-_NO_CONFIDENCE_ENVELOPE": permutations = 0 elif permutations == "99_PERMUTATIONS": permutations = 99 elif permutations == "999_PERMUTATIONS": permutations = 999 else: permutations = 9 if studyAreaMethod == "USER_PROVIDED_STUDY_AREA_FEATURE_CLASS": studyAreaMethod = 1 else: studyAreaMethod = 0 k = KFunction(inputFC, outputTable = outputTable, nIncrements = nIncrements, permutations = permutations, weightField = weightField, begDist = begDist, dIncrement = dIncrement, edgeCorrection = edgeCorrection, studyAreaMethod = studyAreaMethod, studyAreaFC = studyAreaFC) k.report() k.createOutput(outputTable, displayIt = displayIt)
def setupParameters(): #### Get User Provided Inputs #### inputFC = ARCPY.GetParameterAsText(0) depVarName = ARCPY.GetParameterAsText(1).upper() indVarNames = ARCPY.GetParameterAsText(2).upper() indVarNames = indVarNames.split(";") weightsFile = ARCPY.GetParameterAsText(3) kernelWeightsFile = ARCPY.GetParameterAsText(4) pValue = ARCPY.GetParameter(5) useCombo = ARCPY.GetParameter(6) outputFC = ARCPY.GetParameterAsText(7) #### Create SSDataObject #### fieldList = [depVarName] + indVarNames ssdo = SSDO.SSDataObject(inputFC, templateFC=outputFC) #### Setup masterField for ssdo from Model weights file #### masterField1 = AUTILS.setUniqueIDField(ssdo, weightsFile) if masterField1 == None: ARCPY.AddError("The Model weights file format is not valid.") raise SystemExit() #### Setup masterField for ssdo from Kernel weights file #### masterField2 = None wType = kernelWeightsFile[-3:].lower() if wType == "kwt" or wType == "swm": masterField2 = AUTILS.setUniqueIDField(ssdo, kernelWeightsFile) if masterField2 == None: ARCPY.AddError("The Kernel weights file format is not valid.") raise SystemExit() #### Detect if Two Weights Files Are Matched (Same Unique Field) #### if masterField1 != masterField2: ARCPY.AddError("The Model weights file and Kernel weights file have " "different unique ID fields.") raise SystemExit() #### Populate SSDO with Data #### ssdo.obtainData(masterField1, fieldList) #### Resolve Weights File #### patW = None patKW = None try: patW = AUTILS.PAT_W(ssdo, weightsFile) patKW = AUTILS.PAT_W(ssdo, kernelWeightsFile) except: ARCPY.AddError("There is an error occurred when read weights files.") raise SystemExit() #### Run AutoSpace #### auto = AutoSpace_PySAL(ssdo, depVarName, indVarNames, patW, patKW, pValue, useCombo) #### Create Output #### auto.createOutput(outputFC)
def getParametersAsText(indexesForCatalogPath=[]): """ Get a list of all arcpy parameters as text. **Description:** Uses `arcpy.GetParameterAsText`_ to assemble a list of strings representing parameters from the script that is being executed. ie. the input parameters for an ArcGIS toolbox dialog box, an ArcGIS modelbuilder model, or another python script, etc. The optional *indexesForCatalogPath* argument allows you to indicate which indexes must have the full catalog path retrieved. For example, if the layer name is the text returned for the parameter, you can request the full path of the dataset for that parameter by adding its index to a list passed to this function. This seems to be most critical for input parameters - the code produces an error for output parameters, so don't include them in the list of integer indexes **Arguments:** * *indexesForCatalogPath* - Iterable with integer indexes of parameters to get a catalog path for. **Returns:** * list of strings """ textParameters = [] total = arcpy.GetArgumentCount() for count in range(0, total): try: if count in indexesForCatalogPath: # if hasattr(arcpy.GetParameter(count), "value"): # arcpy.AddMessage("Parameter {0} has value attibute".format(count)) # else: # arcpy.AddMessage("Parameter {0} has NO value attibute".format(count)) # check if input parameter is a lyr file with arcpy.Exists if arcpy.Exists(arcpy.GetParameter(count)): parameterAsText = arcpy.Describe( arcpy.GetParameter(count)).catalogPath.strip("'") else: parameterAsText = arcpy.Describe( arcpy.GetParameter( count).dataSource).catalogPath.strip("'") else: parameterAsText = arcpy.GetParameterAsText(count).strip("'") textParameters.append(parameterAsText) except: # We're going to make an assumption that something went wrong with getting parameters, and to preserve # the argument index, add an ESRI null "#". textParameters.append("#") return textParameters
def GetArgs(): lulc_uri = arcpy.GetParameterAsText(0) biophysical_table_uri = arcpy.GetParameterAsText(1) pools_to_calculate = arcpy.GetParameterAsText(2) compute_forest_edge_effects = arcpy.GetParameter(3) tropical_forest_edge_carbon_model_shape_uri = arcpy.GetParameterAsText(4) n_nearest_model_points = arcpy.GetParameter(5) biomass_to_carbon_conversion_factor = arcpy.GetParameter(6) aoi_uri = arcpy.GetParameterAsText(7) try: if not compute_forest_edge_effects: args = { u'lulc_uri': lulc_uri, u'biophysical_table_uri': biophysical_table_uri, u'compute_forest_edge_effects': False, u'workspace_dir': workspace_dir, } if 'all' in pools_to_calculate: args[u'pools_to_calculate'] = u'all' else: args[u'pools_to_calculate'] = u'above_ground' #COMPUTE FOREST EDGE EFFECTS else: args = { u'lulc_uri': lulc_uri, u'biophysical_table_uri': biophysical_table_uri, u'compute_forest_edge_effects': True, u'tropical_forest_edge_carbon_model_shape_uri': tropical_forest_edge_carbon_model_shape_uri, u'n_nearest_model_points': n_nearest_model_points, u'biomass_to_carbon_conversion_factor': biomass_to_carbon_conversion_factor, u'workspace_dir': workspace_dir, } if 'all' in pools_to_calculate: args[u'pools_to_calculate'] = u'all' else: args[u'pools_to_calculate'] = u'above_ground' if aoi_uri and aoi_uri != "#": args[u'aoi_uri'] = aoi_uri except Exception: e = sys.exc_info()[1] arcpy.AddError('An error occurred: {}'.format(e.args[0])) return args
def setup_create_convexhull(): """ メソッド名 : setup_create_convexhull メソッド 概要 : 凸包作成に用いる入力情報の作成 """ in_pt_fc = arcpy.GetParameterAsText(0) out_pt_fc = arcpy.GetParameterAsText(1) group_field = arcpy.GetParameter(2) group_field_name = arcpy.GetParameterAsText(3) create_buffer = arcpy.GetParameter(4) buffer_num = arcpy.GetParameter(5) create_convexhull(in_pt_fc, out_pt_fc, group_field, group_field_name, create_buffer, buffer_num)
def main(): in_table = arcpy.GetParameterAsText(0) out_folder = arcpy.GetParameterAsText(1) output_schema = arcpy.GetParameter(2) rename_fields = arcpy.GetParameter(3) prefix = arcpy.GetParameter(4) new_table_name = arcpy.GetParameterAsText(5) TableToCSV(in_table, out_folder, output_schema, rename_fields=rename_fields, prefix=prefix, new_table_name=new_table_name)
def initialize_params(): in_map = arcpy.GetParameter(0) arcpy.AddMessage("Input map : {0}.".format(in_map)) in_layers = arcpy.GetParameter(1) save_a_copy = arcpy.GetParameterAsText(2) arcpy.AddMessage("Save a copy:" + save_a_copy) out_vtpk = arcpy.GetParameterAsText(3) arcpy.AddMessage("Out VTPK Path:" + out_vtpk) field_name = "lod" return in_map, in_layers, field_name, save_a_copy, out_vtpk
def main(): in_add_features_params = arcpy.GetParameter(0) # in add features params in_add_features_params = in_add_features_params.replace('\\"', '"') try: in_add_features_params = json.loads(in_add_features_params) except: arcpy.SetParameter(2, 'Invalid addFeaturesParams JSON, try again') exit() in_service_url = arcpy.GetParameter(1) token = get_portal_token() add_features_resp = add_features(in_service_url, in_add_features_params, token) arcpy.SetParameter(2, json.dumps(add_features_resp))
def setupParameters(): #### Get User Provided Inputs #### inputFC = ARCPY.GetParameterAsText(0) depVarName = ARCPY.GetParameterAsText(1).upper() indVarNames = ARCPY.GetParameterAsText(2).upper() indVarNames = indVarNames.split(";") weightsFile = ARCPY.GetParameterAsText(3) outputFC = ARCPY.GetParameterAsText(4) useHAC = ARCPY.GetParameter(5) #### Create SSDataObject #### fieldList = [depVarName] + indVarNames ssdo = SSDO.SSDataObject(inputFC, templateFC=outputFC) masterField = AUTILS.setUniqueIDField(ssdo, weightsFile) #### Populate SSDO with Data #### ssdo.obtainData(masterField, fieldList) #### Resolve Weights File #### patW = AUTILS.PAT_W(ssdo, weightsFile) #### Run OLS #### ols = GMError_PySAL(ssdo, depVarName, indVarNames, patW, useHAC=useHAC) #### Create Output #### ols.createOutput(outputFC)
def execute(): in_map = arcpy.GetParameterAsText(0) arcpy.AddMessage("Input map : {0}.".format(in_map)) in_layers = arcpy.GetParameter(1) save_a_copy = arcpy.GetParameterAsText(2) arcpy.AddMessage("Save a copy:" + save_a_copy) RepairLayerSymbology.batch_repairs(in_map,in_layers,save_a_copy)
def setupNearestNeighbor(): """Retrieves the parameters from the User Interface and executes the appropriate commands.""" inputFC = ARCPY.GetParameterAsText(0) distanceConcept = ARCPY.GetParameterAsText(1).upper().replace(" ", "_") displayIt = ARCPY.GetParameter(2) studyArea = UTILS.getNumericParameter(3) concept = WU.conceptDispatch[distanceConcept] #### Create a Spatial Stats Data Object (SSDO) #### ssdo = SSDO.SSDataObject(inputFC, useChordal=True) #### Populate SSDO with Data #### ssdo.obtainDataGA(ssdo.oidName, minNumObs=2) #### Calculate #### nn = NearestNeighbor(ssdo, concept=concept, studyArea=studyArea) #### Report and Set Parameters #### nn.report() try: ARCPY.SetParameterAsText(4, nn.ratioString) ARCPY.SetParameterAsText(5, nn.znString) ARCPY.SetParameterAsText(6, nn.pvString) ARCPY.SetParameterAsText(7, nn.enString) ARCPY.SetParameterAsText(8, nn.nnString) except: ARCPY.AddIDMessage("WARNING", 902) #### Create HTML Output #### if displayIt: htmlOutFile = nn.reportHTML(htmlFile=None) ARCPY.SetParameterAsText(9, htmlOutFile)
def main(): subregion_ned = arcpy.GetParameterAsText(0) nhd_gdb = arcpy.GetParameterAsText(1) burnt_out = arcpy.GetParameterAsText(2) input_burnt = arcpy.GetParameter(3) arcpy.CheckOutExtension("Spatial") if not input_burnt: burn(subregion_ned, nhd_gdb, burnt_out, projection) input_burnt = burnt_out try: clip(input_burnt, nhd_gdb, projection, outfolder) arcpy.Delete_management(input_burnt) cu.multi_msg( "Complete. HUC8 burned clips are now ready for flow direction.") except arcpy.ExecuteError: cu.multi_msg( "Clip failed, try again. Mosaic file is %s and burnt NED file is %s" % (subregion_ned, burnt_ned)) arcpy.AddError(arcpy.GetMessages(2)) except Exception as e: cu.multi_msg( "Clip failed, try again. Mosaic file is %s and burnt NED file is %s" % (subregion_ned, burnt_ned)) cu.multi_msg(e.message) finally: arcpy.CheckInExtension("Spatial")
def main(): """ Main Function """ # Input Parameters layers_to_clip = arcpy.GetParameterAsText(0) area_of_interest = arcpy.GetParameter(1) # Check if valid AOI is provided. It should have at least 1 polygon # feature aoi_featset = arcpy.FeatureSet() aoi_featset.load(area_of_interest) aoi_feat_count = int(arcpy.GetCount_management(aoi_featset)[0]) if aoi_feat_count == 0: arcpy.AddError("Provided AOI has no polygon features." + " Please provide valid AOI for analysis.") return # Download data for provided layers layers_success = loop_req_layers(layers_to_clip, area_of_interest) if not layers_success: return # Create zip file of generated excel files for output output_zip_file = create_zip_folder() if not output_zip_file: return else: # Set generated zip file as output arcpy.AddMessage("Zip file created at : " + str(output_zip_file)) arcpy.SetParameter(2, output_zip_file)
def execute(): in_map = arcpy.GetParameterAsText(0) arcpy.AddMessage(in_map) arcpy.AddMessage("Input map : {0}.".format(in_map)) in_layers = arcpy.GetParameter(1) GenerateBGLayer.batch_dissolve_layer(in_map, in_layers)
def main(): zones_fc = arcpy.GetParameterAsText(0) zone_field = arcpy.GetParameterAsText(1) wetlands_fc = arcpy.GetParameterAsText(2) output_table = arcpy.GetParameterAsText(3) dissolve_wetlands = arcpy.GetParameter(4) # boolean wetlands_in_zones(zones_fc, zone_field, wetlands_fc, output_table, dissolve_wetlands)
def main(): non_overlapping_zones_list = arcpy.GetParameterAsText(0).split(';') # list zone_field = arcpy.GetParameterAsText(1) in_value_raster = arcpy.GetParameterAsText(2) out_table = arcpy.GetParameterAsText(4) is_thematic = arcpy.GetParameter(3) #boolean stats_overlap(non_overlapping_zones_list, zone_field, in_value_raster, out_table, is_thematic)
def main(): zone_fc = arcpy.GetParameterAsText(0) zone_field = arcpy.GetParameterAsText(1) in_value_raster = arcpy.GetParameterAsText(2) out_table = arcpy.GetParameterAsText(4) is_thematic = arcpy.GetParameter(3) #boolean handle_overlaps(zone_fc, zone_field, in_value_raster, out_table, is_thematic)
def GetArgs(): lulc_lookup_table = arcpy.GetParameterAsText(0) lulc_transition_effect_of_carbon_table = arcpy.GetParameterAsText(1) carbon_pool_initial_variables_table = arcpy.GetParameterAsText(2) carbon_pool_transient_variables_table = arcpy.GetParameterAsText(3) baseline_raster = arcpy.GetParameterAsText(4) year_of_baseline = arcpy.GetParameter(5) transition_lulc_raster_list = arcpy.GetParameterAsText(6) transition_lulc_raster_list = transition_lulc_raster_list.split(";") transition_lulc_raster_list = [ rast.replace("'", "") for rast in transition_lulc_raster_list ] transition_year_list = arcpy.GetParameterAsText(7) transition_year_list = transition_year_list.split(";") do_economic_analysis = arcpy.GetParameter(8) use_price_table = arcpy.GetParameter(9) price = arcpy.GetParameter(10) interest_rate = arcpy.GetParameter(11) discount_rate = arcpy.GetParameter(12) price_table = arcpy.GetParameterAsText(13) analysis_year = arcpy.GetParameter(14) outList = [] try: args = { u'carbon_pool_initial_uri': carbon_pool_initial_variables_table, u'carbon_pool_transient_uri': carbon_pool_transient_variables_table, u'do_economic_analysis': do_economic_analysis, u'do_price_table': use_price_table, u'lulc_baseline_map_uri': baseline_raster, u'lulc_baseline_year': year_of_baseline, u'lulc_lookup_uri': lulc_lookup_table, u'lulc_transition_maps_list': transition_lulc_raster_list, u'lulc_transition_matrix_uri': lulc_transition_effect_of_carbon_table, u'lulc_transition_years_list': transition_year_list, u'workspace_dir': workspace_dir, #u'discount_rate': discount_rate } if do_economic_analysis: args[u'discount_rate'] = discount_rate if use_price_table: args[u'price_table_uri'] = price_table else: args[u'interest_rate'] = interest_rate args[u'price'] = price if analysis_year: args[u'analysis_year'] = analysis_year except Exception: e = sys.exc_info()[1] arcpy.AddError('An error occurred: {}'.format(e.args[0])) return args
def spatialJoin(self): pp = self.ProgressPrinter.newProcess(inspect.stack()[0][3], 1, 1).start() target_features = arcpy.GetParameterAsText(0) join_features = arcpy.GetParameterAsText(1) out_fc = arcpy.GetParameterAsText(2) keep_all = arcpy.GetParameter(3) spatial_rel = arcpy.GetParameterAsText(4).lower() self.SpatialJoinLargestOverlap(target_features, join_features, out_fc, keep_all, spatial_rel) pp.finish()
def setup_create_inside_buffer(): """ メソッド名 : setup_create_inside_buffer メソッド 概要 : バッファー作成に用いる入力情報の作成 """ in_poly_fc = arcpy.GetParameterAsText(0) out_poly_fc = arcpy.GetParameterAsText(1) buffer_distace = arcpy.GetParameter(2) create_inside_buffer(in_poly_fc, out_poly_fc, buffer_distace)
def main(): nhd_gdb = arcpy.GetParameterAsText(0) # NHD subregion file geodatabase ned_dir = arcpy.GetParameterAsText(1) # Folder containing NED ArcGrids ned_footprints_fc = arcpy.GetParameterAsText(2) out_dir = arcpy.GetParameterAsText(3) # Output folder is_zipped = arcpy.GetParameter(4) # Whether NED tiles are zipped or not mosaic_workspace = stage_files(nhd_gdb, ned_dir, ned_footprints_fc, out_dir, is_zipped) available_ram = arcpy.GetParameterAsText(5) mosaic(mosaic_workspace, mosaic_workspace, available_ram)
def run(): """ Run the BAL calculations. """ # add subfolders into path cmd_folder = os.path.realpath( os.path.abspath( os.path.split(inspect.getfile(inspect.currentframe()))[0])) if cmd_folder not in sys.path: sys.path.insert(0, cmd_folder) cmd_subfolder = pjoin(cmd_folder, "utilities") if cmd_subfolder not in sys.path: sys.path.insert(0, cmd_subfolder) # get input parameters from toolbox interface dem = arcpy.GetParameterAsText(0) veg = arcpy.GetParameterAsText(1) remap = arcpy.GetParameterAsText(2) output_folder = arcpy.GetParameterAsText(3) fdi = arcpy.GetParameter(4) extent = arcpy.GetParameter(5) dem_sr = arcpy.Describe(dem).spatialReference arcpy.AddMessage("DEM's spatial reference type is {0}".format(dem_sr.type)) if dem_sr.type == "Projected": # find effective AOI based on the input parameters mask = find_aoi(extent, dem, veg) try: # calculate the BAL for the effective AOI bal_calc(veg, dem, fdi, output_folder, remap, mask) arcpy.AddMessage("Successfully completed BAL calculation!") except Exception as err: # Report any exceptions back arcpy.AddError(err) else: arcpy.AddError("To go ahead, the DEM needs to be projected first")
def main(): zone_fc = arcpy.GetParameterAsText(0) zone_field = arcpy.GetParameterAsText(1) unflat_table = arcpy.GetParameterAsText(2) in_value_raster = arcpy.GetParameterAsText(3) is_thematic = arcpy.GetParameter(4) # boolean out_table = arcpy.GetParameterAsText(5) rename_tag = arcpy.GetParameterAsText(6) # optional units = arcpy.GetParameterAsText(7) # optional handle_overlaps(zone_fc, zone_field, in_value_raster, out_table, is_thematic, unflat_table, rename_tag, units)
def GetArgs(): try: aoi_path = arcpy.GetParameterAsText(0) start_year = arcpy.GetParameterAsText(1) end_year = arcpy.GetParameterAsText(2) compute_regression = arcpy.GetParameter(3) predictor_table_path = arcpy.GetParameterAsText(4) scenario_predictor_table_path = arcpy.GetParameterAsText(5) grid_aoi = arcpy.GetParameter(6) grid_type = arcpy.GetParameterAsText(7) cell_size = arcpy.GetParameter(8) args = { u'aoi_path': aoi_path, u'start_year': start_year, u'end_year': end_year, u'compute_regression': compute_regression, u'grid_aoi': grid_aoi, u'workspace_dir': workspace_dir, u'predictor_table_path': u'', u'scenario_predictor_table_path': u'', } if predictor_table_path and predictor_table_path != '#': args[u'predictor_table_path'] = predictor_table_path if scenario_predictor_table_path and scenario_predictor_table_path != '#': args[ u'scenario_predictor_table_path'] = scenario_predictor_table_path if grid_aoi: args[u'grid_type'] = grid_type args[u'cell_size'] = cell_size except Exception: e = sys.exc_info()[1] arcpy.AddError('An error occurred: {}'.format(e.args[0])) return args
def execute(): in_map = arcpy.GetParameterAsText(0) arcpy.AddMessage(in_map) arcpy.AddMessage("Input map : {0}.".format(in_map)) # in_layer = arcpy.GetParameterAsText(1) # arcpy.AddMessage("Input Layer : {0}.".format(in_layer)) in_layers = arcpy.GetParameter(1) batch_dissolve_layer(in_map, in_layers) # execute()