flds = arcpy.GetParameterAsText(1) lst_flds = flds.split(';')
Hi,Sorry it took so long to say thank you. After working through the tables and the code I finally got it to run properly without any errors. It was amazing. Thank you. I put together this code for the IDW so that someone can select several different fields from the same table and run IDW on the data for that set of points. It's really crude but it works I suppose. Again I want to thank you for all your help. If you have any suggestions on the stuff at the bottom let me know. import arcpyfrom arcpy import envfrom arcpy.sa import *arcpy.CheckOutExtension("Spatial")env.workspace = "C:/Users/Anne/Desktop/Python/finalproj"#Set Variablespoints = "Export_Output.shp"zfield1 = "pH"zfield2 = "Pphate"zfield3 = "K"zfield4 = "CA"zfield5 = "Mg"#First Runoutidw1 = Idw(points, zfield1)outidw1.save("C:/Users/Anne/Desktop/Python/finalproj/data/outputs/ab10ph")#Second Runoutidw2 = Idw(points, zfield2)outidw2.save("C:/Users/Anne/Desktop/Python/finalproj/data/outputs/ab10pphate")#Third Runoutidw3 = Idw(points, zfield3)outidw3.save("C:/Users/Anne/Desktop/Python/finalproj/data/outputs/ab10ll")#Fourth Runoutidw4 = Idw(points, zfield4)outidw4.save("C:/Users/Anne/Desktop/Python/finalproj/data/outputs/ab10ca")#Fifth Runoutidw5 = Idw(points, zfield5)outidw5.save("C:/Users/Anne/Desktop/Python/finalproj/data/outputs/ab10mg")
import arcpy, os arcpy.CheckOutExtension("Spatial") ws_out = "C:/Users/Anne/Desktop/Python/finalproj/data/outputs" env.workspace = ws_out # set it to your output workspace arcpy.env.overwriteOutput = True #Set Variables points = "C:/Users/Anne/Desktop/Python/finalproj/Export_Output.shp" # dictionary with fieldnames and output raster names d = {'pH': 'ab10ph', 'Pphate': 'ab10pphate', 'K': 'ab10ll', 'CA': 'ab10ca', 'Mg': 'ab10mg'} # loop through the dictionary for fieldname, rasname in d.items(): # are you sure you want to accept default cellsize, power and search radius? outidw = arcpy.sa.Idw(points, fieldname) outidw.save(rasname) # no path included, so saved to (output) workspace # return the sa license arcpy.CheckInExtension("Spatial")
l = ['pH', 'Pphate', 'K', 'CA', 'Mg'] ras_prefix = 'ab10' for name in l: outidw = arcpy.sa.Idw(points, name) outidw.save('{0}{1}'.format(ras_prefix, name))
spref = 4326
spref = arcpy.SpatialReference(4326)
out_layer = "F:/work/python"
import arcpy, os from arcpy import env ws_in = "F:/work/python" # could use arcpy.GetParameterAsText(0) ws_out = "F:/work/python/output" # could use arcpy.GetParameterAsText(1) env.workspace = ws_in tables = arcpy.ListTables() xc = "long" yc = "lat" spref = arcpy.SpatialReference(4326) XYeventname = "measurements" for tbl in tables: arcpy.MakeXYEventLayer_management(tbl, xc, yc, XYeventname, spref) # assuming you have DBF tables, strip the extension: fclass = os.path.join(ws_out, tbl.strip(".dbf")) # make the featureclass arcpy.CopyFeatures_management(XYeventname, fclass)
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.