tableList = [] for missingValues in missingAPNs: with arcpy.da.SearchCursor(table, field_names=fields, where_clause="{} = '{}'".format( arcpy.AddFieldDelimiters( table, 'pl_csa_apn'), missingValues)) as cursor: for row in cursor: tableList.append(row) return tableList # def createAndbuildTable(outPath) outTable = arcpy.GetParameterAsText(0) psomas_master = r'D:\MillerSpatial\EDA\EDA Test.gdb\psomas_master' dataFiles_master = r'D:\MillerSpatial\EDA\EDA Test.gdb\dataFile_master' psomas_set = searchForAPNs(psomas_master, 'APN') dataFile_set = searchForAPNs(dataFiles_master, 'pl_csa_apn') dataDifference = dataFile_set.difference(psomas_set) outList = buildTableList(dataFiles_master, dataDifference) print dataFile_set.difference(psomas_set) # def findMissing(m, p): # foundAPNs = [] # missingAPNList = [] #
#Import system modules import sys, string, os, arcpy, math, traceback, glob, numpy from arcpy.sa import * from datetime import datetime # Allow output to overwrite... arcpy.env.overwriteOutput = True # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") try: #INPUT ARGUMENTS DEM = arcpy.GetParameterAsText(0) # DEM Name Folder = arcpy.GetParameterAsText(1) # Folder Name for the results Code = arcpy.GetParameterAsText(2) # Short Name of the Basin bl_tresh = arcpy.GetParameterAsText(3) # treshold area in km2 for stream network #Get initial time Init_Time=datetime.now() suff_ord = bl_tresh if "." in bl_tresh: suff_ord = suff_ord.replace(".","") #GETTING THE NAME OF THE DEM DEM_name = os.path.basename(DEM).split('.')[0] ldn=len(DEM_name) #Current working directory
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # Suitable_land_tool.py # Created on: 2018-04-20 18:24:50.00000 # (generated by ArcGIS/ModelBuilder) # Usage: Suitable_land_tool <Boundaries> # Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy True = arcpy.env.overwriteOutput # Script arguments Boundaries = arcpy.GetParameterAsText(0) if Boundaries == '#' or not Boundaries: Boundaries = "D:\\WCGIS\\Geog485\\Lesson1\\Lesson1\\us_boundaries.shp" # provide a default value if unspecified # Local variables: Cities = "us_cities" Roads = "D:\\WCGIS\\Geog485\\Lesson1\\Lesson1\\us_roads.shp" Suitable_land = Boundaries Distance__value_or_field_ = "10 Miles" Distance__value_or_field___2_ = "10 Miles" Buffered_cities = "C:\\Users\\Alaa\\Documents\\ArcGIS\\Default.gdb\\us_cities_Buffer1" Bufferwd_Roads = "C:\\Users\\Alaa\\Documents\\ArcGIS\\Default.gdb\\us_roads_Buffer1" Intersected_buffers = "C:\\Users\\Alaa\\Documents\\ArcGIS\\Default.gdb\\us_cities_Buffer_Intersect" # Process: Buffer the cities arcpy.Buffer_analysis(Cities, Buffered_cities, Distance__value_or_field_, "FULL", "ROUND", "ALL", "", "PLANAR")
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # Ctrete Track.py # Created on: 2014-02-10 13:52:57.00000 # (generated by ArcGIS/ModelBuilder) # Usage: Ctrete Track <GeoTweets> <Track_Line> # Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy # Script arguments GeoTweets = arcpy.GetParameterAsText(0) if GeoTweets == '#' or not GeoTweets: GeoTweets = "GeoTweets" # provide a default value if unspecified Track_Line = arcpy.GetParameterAsText(1) if Track_Line == '#' or not Track_Line: Track_Line = "C:\\Documents and Settings\\weiry\\My Documents\\ArcGIS\\Default.gdb\\GeoTweets_TrackIntervalsToLi" # provide a default value if unspecified # Local variables: GeoTweet_dbf__9_ = Track_Line GeoTweet_dbf__12_ = GeoTweet_dbf__9_ GeoTweet_dbf__7_ = GeoTweet_dbf__12_ GeoTweet_dbf__11_ = GeoTweet_dbf__7_ GeoTweet_dbf__14_ = GeoTweet_dbf__11_ GeoTweet_dbf__13_ = GeoTweet_dbf__14_ GeoTweet_dbf__10_ = GeoTweet_dbf__13_ GeoTweet_dbf__18_ = GeoTweet_dbf__10_ GeoTweet_dbf__16_ = GeoTweet_dbf__18_
#Batch reprojection Tool #Malle Carrasco-Harris 4/11/16 #Make a user-friendly tool to reproject raw datasets into target projection #Left print script to be adapted later. import arcpy from arcpy import env env.overwriteOutput = True try: #Input parameters env.workspace = arcpy.GetParameterAsText(0) #folder/gdb that is workspace target = arcpy.GetParameterAsText( 1) #fc that has the desired spatial reference outGDB = arcpy.CreateFileGDB_management( arcpy.GetParameterAsText(2), arcpy.GetParameterAsText(3)) #new gdb that will hold output fc inFC = arcpy.ListFeatureClasses() #feature classes in workspace print "The Feature classes in this folder are ", inFC targSpatial = arcpy.Describe( target).spatialReference.name #desired spatial reference.name object targSR = arcpy.Describe( target).spatialReference #desired spatial reference object print "The desired spatial reference is ", targSpatial listProjFC = [] #empty list to hold projected feature classes
# -*- coding: utf-8 -*- """ Created on Thu Jun 19 10:19:00 2014 @author: paulinkenbrandt """ import arcpy import numpy as np # input table having the fields Cl, HCO3, CO3, SO4, Na, K, Ca, Mg infile = arcpy.GetParameterAsText(0) # field having unique station identifier stid = arcpy.GetParameterAsText(1) # function to calculate charge balance def chrgbal(Ca, Mg, Na, K, Cl, HCO3, CO3, SO4, NO3, NO2): # Multipliers to convert from mg/l to meq/l d = { 'Ca': 0.04990269, 'Mg': 0.082287595, 'Na': 0.043497608, 'K': 0.02557656, 'Cl': 0.028206596, 'HCO3': 0.016388838, 'CO3': 0.033328223, 'SO4': 0.020833333, 'NO2': 0.021736513, 'NO3': 0.016129032
print "Exception on " + option dict1[option] = None return dict1 # FLAGS_FC = r'C:\Data\IOM\IOM.sde\IOM.DBO.Flags' # surveyName = "RoundIISurvey" configfile = r'C:\Data\IOM\Scripts\CONFIG.INI' ####CONFIG FILE PARAMETERS########################## Config = ConfigParser.ConfigParser() Config.read(configfile) conn = ConfigSectionMap("ALL")['databaseconnection'] FLAGS_FC = arcpy.GetParameterAsText(0) surveyName = arcpy.GetParameterAsText(1) def getValues(conn): arcpy.env.workspace = conn fc = surveyName fields = arcpy.ListFields(fc) rows = arcpy.SearchCursor(fc) edit = arcpy.da.Editor(conn) edit.startEditing(True) edit.startOperation() for row in rows:
updateCursor = arcpy.da.UpdateCursor(dataPath,updateFields,SQL) for row in updateCursor: row[0] = workHeadquarters updateCursor.updateRow(row) del updateCursor # Stop the edit operation. edit.stopOperation() # Stop the edit session and save the changes edit.stopEditing(True) #### End function #### #### Get input from user #### # Script input parameters: sdeWorkspace = arcpy.GetParameterAsText (0) #SDE Connection file txt_input = arcpy.GetParameterAsText (1) # .txt file with feederIDs workHQ_input = arcpy.GetParameterAsText (2) # work headquarters code #makes a list of feeder IDs from a TXT file feederList = [] if txt_input : fhand = open(txt_input) for i in fhand: i = i.strip() feederList.append(str(i)) fhand.close() ###Data paths being updated by calculateHQ() function#### #!!! SUBTYPECD <> 7
unitType, locationDescription, placeType, fullSiteAddress, aliasStreetName, aliasStreetName2, aliasStreetName3, aliasStreetName4, postalCommunity, msagCommunity, emergencyServiceNumber, latitude, longitude, comments, status] arcpy.AddMessage('Writing field mapping parameters...') write_config(p_names,p_vals,config,section) cfgpath = dirname(realpath(__file__)) cfgfile = join(cfgpath, "{}".format(config_file)) with open(cfgfile, "w") as cfg: arcpy.AddMessage('Saving configuration "{}"...'.format(cfgfile)) config.write(cfg) arcpy.AddMessage("Completed configuration") if __name__ == '__main__': argv = tuple(arcpy.GetParameterAsText(i) for i in range(arcpy.GetArgumentCount())) main(*argv)
#------------------------------ #------------path-------------- # 在导入的情况下 # arcpy.AddMessage("CURRENT: {}".format(os.getcwd())) # CURRENT: C:\Windows\system32 # 返回工具箱的完整名称 toolbox = os.path.abspath(sys.argv[0]) tool_dir = os.path.abspath(os.path.dirname(toolbox)) # lyr dir_lyr = os.path.join(tool_dir, "lyr") # StyleTool/lyr # 制图表达文件存储位置 representation = os.path.join(tool_dir, "Representation") rp_gdb = os.path.join(representation, "rep_base.gdb") #------------path-------------- #------------------------------ #------------------------------ #----------workspace----------- arcpy.env.workspace = os.path.dirname(arcpy.GetParameterAsText(2)) work = arcpy.env.workspace #----------workspace----------- #------------------------------ # arcpy.env.addOutputsToMap = True lyr_file = os.path.join(dir_lyr, "opacity.lyr") OpacityContour(arcpy.GetParameterAsText(0), arcpy.GetParameterAsText(1), lyr_file, arcpy.GetParameterAsText(2))
def verificaDS(destino, lista): ret = "PROBLEMA" for i in lista: g1 = destino + os.path.sep + i if arcpy.Exists(g1): imprimir("DESTINO ===> " + g1) ret = i break return ret if __name__ == '__main__': cws = r"c:\temp\actas.gdb" # cws = arcpy.GetParameterAsText(0) archivoE = r"C:\D\proyectos\2019\ARAUCO_CARTO\PLANILLAS\Actas Cerradas_2019_S4_Julio.xlsx" # archivoE = arcpy.GetParameterAsText(1) destino = arcpy.GetParameterAsText(2) for suf in ["", "0", "1", "2", "3", "4", "5", "6", "7"]: tabla = cws + os.path.sep + "UNION" + suf eliminarObjeto(tabla) #if not arcpy.Exists(destino + os.path.sep + RMA): # imprimir("PROBLEMAS NO EXISTE "+ RMA +" en "+destino) #else: DetectaActasCerradas(cws) if tipoBase(destino) == "LocalDatabase": oRMA = oRMA.replace(uOracle + ".", "") oRMA1 = oRMA1.replace(uOracle + ".", "")
data[len(lonSeries) - l - 1][t] = value title = meta['shortName'] dateRange = "%s - %s" % (timeSeries[0].strftime('%b %Y'), timeSeries[-1].strftime('%b %Y')) return createHoffmueller(data, lonSeries, timeSeries, "Longitude", "%s\n%s" % (title, dateRange), interpolate='nearest') # Get the input parameters host_url = arcpy.GetParameterAsText(0) dataset = arcpy.GetParameterAsText(1) input_feature = arcpy.GetParameter(2) start_time = pd.to_datetime( arcpy.GetParameterAsText(3)).strftime('%Y-%m-%dT%H:%M:%SZ') end_time = pd.to_datetime( arcpy.GetParameterAsText(4)).strftime('%Y-%m-%dT%H:%M:%SZ') # get coordinates by calculating geometric attributes arcpy.MakeFeatureLayer_management(input_feature, "layer") arcpy.AddGeometryAttributes_management("layer", "EXTENT") rows = arcpy.SearchCursor("layer", fields="EXT_MIN_X;EXT_MIN_Y;EXT_MAX_X;EXT_MAX_Y") row = next(rows) min_lon = row.getValue("EXT_MIN_X")
try: # Figure out what version of ArcGIS they're running BBB_SharedFunctions.DetermineArcVersion() if BBB_SharedFunctions.ProductName == "ArcGISPro" and BBB_SharedFunctions.ArcVersion in ["1.0", "1.1", "1.1.1"]: arcpy.AddError("The BetterBusBuffers toolbox does not work in versions of ArcGIS Pro prior to 1.2.\ You have ArcGIS Pro version %s." % BBB_SharedFunctions.ArcVersion) raise CustomError #----- SQLize the GTFS data----- arcpy.AddMessage("SQLizing the GTFS data...") arcpy.AddMessage("(This will take a while for large datasets.)") # GTFS files inGTFSdir = arcpy.GetParameterAsText(0) SQLDbase = arcpy.GetParameterAsText(1) if not SQLDbase.lower().endswith(".sql"): SQLDbase = SQLDbase + ".sql" # Fix up list of GTFS datasets inGTFSdirList = inGTFSdir.split(";") # Remove single quotes ArcGIS puts in if there are spaces in the filename. for d in inGTFSdirList: if d[0] == "'" and d[-1] == "'": loc = inGTFSdirList.index(d) inGTFSdirList[loc] = d[1:-1] # The main SQLizing work is done in the sqlize_csv module # written by Luitien Pan. # Connect to or create the SQL file.
#--------------------------------------------------------------------------- # # RemoveLineBreaks.py # Mike Fleming [email protected] # Created: 19/06/2016 # Last updated 19/06/2016 # Description: Removes line breaks and excess spaces from the specified text field. # #--------------------------------------------------------------------------- # Import modules import arcpy, time # User-supplied parameters feat_layer = arcpy.GetParameterAsText(0) fieldname = arcpy.GetParameterAsText(1) # Setup status output scriptName = 'RemoveLineBreaks.py' StartTime = time.strftime("%#c", time.localtime()) startText = "____________________Script started successfully.____________________" arcpy.AddMessage(" " * 3) arcpy.AddMessage(" -<>-<>-<>-" * 3) arcpy.AddMessage(" ") arcpy.AddMessage(startText) arcpy.AddMessage("\n") arcpy.AddMessage(StartTime) # Main with arcpy.da.UpdateCursor(feat_layer, fieldname) as cur: for row in cur:
a given dataset Created By: Alice Yepremyan Date: 1/28/2020 -----------------------------------------------------------------------------""" import arcpy import json import requests import datetime import matplotlib.pyplot as plt import pandas as pd arcpy.env.overwriteOutput = True # Get the input parameters host_url = arcpy.GetParameterAsText(0) ds = arcpy.GetParameterAsText(1) ds2 = arcpy.GetParameterAsText(2) input_feature = arcpy.GetParameter(3) start_time = pd.to_datetime( arcpy.GetParameterAsText(4)).strftime('%Y-%m-%dT%H:%M:%SZ') end_time = pd.to_datetime( arcpy.GetParameterAsText(5)).strftime('%Y-%m-%dT%H:%M:%SZ') # get coordinates by calculating geometric attributes arcpy.MakeFeatureLayer_management(input_feature, "layer") arcpy.AddGeometryAttributes_management("layer", "EXTENT") rows = arcpy.SearchCursor("layer", fields="EXT_MIN_X;EXT_MIN_Y;EXT_MAX_X;EXT_MAX_Y") row = rows.next()
# Script Name: D8DistanceToStreams # # Created By: David Tarboton # Date: 9/29/11 # Import ArcPy site-package and os modules import arcpy import os import subprocess # Inputs inlyr = arcpy.GetParameterAsText(0) desc = arcpy.Describe(inlyr) p = str(desc.catalogPath) arcpy.AddMessage("\nInput D8 Flow Direction Grid: " + p) inlyr1 = arcpy.GetParameterAsText(1) desc = arcpy.Describe(inlyr1) src = str(desc.catalogPath) arcpy.AddMessage("Input Stream Raster Grid: " + src) thresh = arcpy.GetParameterAsText(2) arcpy.AddMessage("Threshold: " + thresh) # Input Number of Processes inputProc = arcpy.GetParameterAsText(3) arcpy.AddMessage("Number of Processes: " + inputProc) # Output dist = arcpy.GetParameterAsText(4) arcpy.AddMessage("Output Distance To Streams: " + dist)
import arcpy, os, sys # PARAMETERS AND DIRECTORIES INPUT_GDBs = arcpy.GetParameterAsText(0) Output_Folder = arcpy.GetParameterAsText(1) OH_Reatrib_GDBs = sorted(INPUT_GDBs.split(";")) INPUT_GDBs #FinalDeliverable_GDBs = os.path.join(Output_Folder,"REATTRIBUTED_OH_GDBs") # FUNCTIONS def split_following_num(s): prev_char = '' for i, char in enumerate(s): if char == '_' and prev_char in '0123456789': return s[:i] prev_char = char ## Fields needing swap: OH , DC_VENDOR, DC_AF for circuit_GDB in OH_Reatrib_GDBs :
# dissolve.py # Created on: 2016-04-26 12:03:19.00000 # (generated by ArcGIS/ModelBuilder) # Usage: dissolve <input_data> # Description: # --------------------------------------------------------------------------- #run this second no args #C:\Python27\ArcGIS10.3\python.exe tra.py # Import arcpy module import arcpy import json import os # Script arguments input_data = arcpy.GetParameterAsText(0) # Local variables: #input data path = "E:\\ncdeq\\DMS_RBRP.gdb" temp_dissolve = "E:\\DMS_RBRP.gdb\\temp_dissolve" #output data outPathGDB = "E:\\ncdeq\\code\\ncdeq-data" outGDB = "RDRBP_AGO.gdb" #uplift data with open('json/tra_mapping.json') as data_file: tra_data = json.load(data_file)
#Using a file folder with attachments that have a common naming scheme (with the unique identifier separated by an underscore), this script creates a match csv table, then joins the files in a folder #to a layer file as attachments. Note: this script is only configured for files with a single underscore delineating the unique identifier. It must be modified for additional underscores or other #separator character as appropriate. Inputs: attachments folder, layer, the field from the layer on which the join will be based, and the matching join field to be created in the csv file. #Author/contact: Emma Hatcher/[email protected] import arcpy import csv import os from arcpy import env from os import listdir #Inputs: folder with attachments, the layer to attach to, the name of the attribute field the match is based on attachments_folder = arcpy.GetParameterAsText(0) attachments_layer = arcpy.GetParameterAsText(1) #Define match field on which to base join match_field = arcpy.GetParameterAsText(2) f_id_name = arcpy.GetParameterAsText(3) #Enable Attachments arcpy.EnableAttachments_management(attachments_layer) attachments_table = attachments_folder + "\\" + "attachments_Table.csv" #Parse file names to extract unique identifier (must be separated from file name structure by an '_'), then write csv table with open(attachments_table, 'wb') as output: writer = csv.writer(output, delimiter=",") writer.writerow([str(f_id_name), 'Attachment']) for f in os.listdir(attachments_folder):
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # The GNU General Public License can be found at # <http://www.gnu.org/licenses/>. #------------------------------------------------------------------------------ #!/usr/bin/env python # Take courage my friend help is on the way import arcpy #workspc = arcpy.GetParameterAsText(0) output = arcpy.GetParameterAsText(0) #arcpy.env.workspace = workspc arcpy.env.overwriteOutput = "True" fc1="Incident_Info" rows = arcpy.SearchCursor(fc1) row = rows.next() while row: # you need to insert correct field names in your getvalue function Incident_Name = row.getValue("Incident_Name") Incident_Type = row.getValue("Incident_Type") Environment = row.getValue("Environment") Eco_Region = row.getValue("Eco_Region") Pop_Den = row.getValue("Pop_Den")
x21 = i - 1 y31 = j - 1 y21 = j z = float(view_elevation) - (float(i)*(float(y21*z31) - float(y31*z21)) + float(j)*(float(z21*x31) - float(z31*x21))) / \ float(x21*y31-x31*y21) if localE[i][j] > z: visible[i][j] = 1 lowestE[i][j] = localE[i][j] else: lowestE[i][j] = z if __name__ == '__main__': # import file and getAttributes path = arcpy.GetParameterAsText(0) point_text = arcpy.GetParameterAsText(1) defaultheight = float(arcpy.GetParameterAsText(2)) output = arcpy.GetParameterAsText(3) raster = arcpy.Raster(path) lon = float(point_text.split(' ')[0]) lat = float(point_text.split(' ')[1]) viewpoint = arcpy.Point(lon, lat) # defaultheight=0.0 describe = arcpy.Describe(raster) cell_size_x = describe.meanCellWidth cell_size_y = describe.meanCellHeight spatialReference = describe.spatialReference extent = describe.Extent rows = raster.height columns = raster.width