3

I am unable to find any info on how to use ModelBuilder to run a certain spatial analysis function on each column in a table.

I have a table to sample locations and at each location there are a series of measures (e.g. temperature, flow rate, number of certain species). For each of those attributes (columns in the table), I was to run the IDW function from the surface tools.

This would be easy if I had each attribute in a separate shp/feature class, but not very efficient. I tried Iterate Feature Selection, but was unable to pass the field name as the Z value in the IDW function.

This is for ArcGIS 10.1 (Basic and Spatial Analyst license)

8

I believe you will need to build a small Python script and paste that into your Model. You would use the ArcPy module and build a field list on your layer:

fieldList = arcpy.ListFields("C:/Data/MyGIS.gdb/MyLayer")

and then you would iterate through the fieldList using a for loop, for example

for field in fieldList:
    #run your spatial analysis function on field
  • Thanks! The ListFields() is super handy. I took it out of model builder now and am trying to do it all in a Python script. I had figure there would be an iterator for that, but it now gives me a good reason to work with Py. – Mr.ecos Mar 18 '13 at 21:02
  • 1
    I am also trying to do the exact same thing but having a hard time to make it work, can you share how you did it in Py or model builder? – Uttam Paudel Jun 23 '13 at 5:15
  • This just helped me out with the Global Moran's I tool. Worth adding that the field object in Arc has properties and tools may be after field.name rather than field. They may also throw an error depending on the field.type. – Oliver Burdekin Jul 24 '14 at 1:24
  • Could you elaborate on the "run your spatial analysis function on field" bit please? What shall be the script be like in ArcPy? – AndrewLebron Oct 18 '17 at 14:29
  • 1
    @AndrewLebron, regarding your previous post, Kernel Density is another function in arcpy which can be run through python interpreter in ArcGIS. For example interim=arcpy.sa.KernelDensity("C:/Data/MyGIS.gdb/MyLayer",field.name,100,500,'SQUARE_KILOMETERS','EXPECTED_COUNTS') will produce kernel density raster and assign to a temporary (as long as not saved) raster. Then you can save this as interim.save(("C:/Data/MyGIS.gdb/MyLayer_Kernel_%s" %field.name). – fatih_dur Oct 19 '17 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.