Field name in extract multi-values to points with iterator

3686
4
Jump to solution
06-26-2013 03:01 PM
RebeccaShaftel
New Contributor
Hi - I am trying to iterate over ~1300 rasters and add the values to a point feature class in a file geodatabase.  I'd like the field names to match the original raster names, but it doesn't work out that way.  I tried using in-line variable substitution for the output field name in the extract multi-values to points tool, but it doesn't seem to be working (%Name%).  I left it empty as well, but it comes up with a strange naming convention and doesn't use the actual raster name for the field names.  I've attached the model below.


[ATTACH=CONFIG]25516[/ATTACH]
0 Kudos
1 Solution

Accepted Solutions
RyanDeBruyn
Esri Contributor
Hi Rebecca,  unfortunatelty this is an issue with the tool not updating the default name for each iteration and not being able to handle inline variables.  A defect has been submitted (reference NIM087496).

As for a workaround. How famililar are you with python?  A pretty simple python expression (see attached python script) can accomplish this.  If you require a model builder tool as part of a bigger workflow, you could always modify this to create a script tool which you can use in a model.

The code is used to create a list of rasters from a workspace (much like the iterator does).  I have provided a wildcard option as well to select only rasters with the characters "_b" in the name.  This multivalue list can then be used as input to the ExtractMultivaluesToPoints tool.  The field names will default to the same name as the input raster.

Based on your description this should provide you with the desired output.

Here is a following code example:

inRasterWksp = r"D:\data\rasters.gdb" inPnts = r"D:\data\fgdb.gdb\randPnts"  arcpy.CheckOutExtension("Spatial") arcpy.env.workspace = inRasterWksp  #create a list of rasters (GRID only) with "-b" in the name rasters = arcpy.ListRasters("*_b*","")  #run tool with all rasters in the list accepting default field names result = arcpy.sa.ExtractMultiValuesToPoints(inPnts,rasters)



Good luck. I hope this helps.
-Ryan

View solution in original post

0 Kudos
4 Replies
ShitijMehta
Esri Regular Contributor
Hi bshaftel,

Using iterator means iterating one raster at a time: per iteration. This single raster in each iteration goes as input to the extract multi values to point tool as a connection to the Input Rasters parameter. This Input rasters parameter takes multiple rasters at one time (it is multivalue value table) - With this in information -are you trying to run the extract multi values to point tool on each raster one at a time per iteration? or you intend to add all the rasters together to this tool?

Yes, the %Name% is not working with the value list parameter of this tool at present. It is mostly a bug or a current limitation. I could find and let you know.

Let me know what you want to do with the extract tool, may be there is a workaround.
0 Kudos
RebeccaShaftel
New Contributor
I am trying to add each raster value separately as a new field to the point feature class. 

If you have a workaround to get the raster name added as the field name, that would be great.

thanks
0 Kudos
RyanDeBruyn
Esri Contributor
Hi Rebecca,  unfortunatelty this is an issue with the tool not updating the default name for each iteration and not being able to handle inline variables.  A defect has been submitted (reference NIM087496).

As for a workaround. How famililar are you with python?  A pretty simple python expression (see attached python script) can accomplish this.  If you require a model builder tool as part of a bigger workflow, you could always modify this to create a script tool which you can use in a model.

The code is used to create a list of rasters from a workspace (much like the iterator does).  I have provided a wildcard option as well to select only rasters with the characters "_b" in the name.  This multivalue list can then be used as input to the ExtractMultivaluesToPoints tool.  The field names will default to the same name as the input raster.

Based on your description this should provide you with the desired output.

Here is a following code example:

inRasterWksp = r"D:\data\rasters.gdb" inPnts = r"D:\data\fgdb.gdb\randPnts"  arcpy.CheckOutExtension("Spatial") arcpy.env.workspace = inRasterWksp  #create a list of rasters (GRID only) with "-b" in the name rasters = arcpy.ListRasters("*_b*","")  #run tool with all rasters in the list accepting default field names result = arcpy.sa.ExtractMultiValuesToPoints(inPnts,rasters)



Good luck. I hope this helps.
-Ryan
0 Kudos
PatriciaPendleton1
New Contributor
Hi Rebecca,  unfortunatelty this is an issue with the tool not updating the default name for each iteration and not being able to handle inline variables.  A defect has been submitted (reference NIM087496).

As for a workaround. How famililar are you with python?  A pretty simple python expression (see attached python script) can accomplish this.  If you require a model builder tool as part of a bigger workflow, you could always modify this to create a script tool which you can use in a model.

The code is used to create a list of rasters from a workspace (much like the iterator does).  I have provided a wildcard option as well to select only rasters with the characters "_b" in the name.  This multivalue list can then be used as input to the ExtractMultivaluesToPoints tool.  The field names will default to the same name as the input raster.

Based on your description this should provide you with the desired output.

Here is a following code example:

inRasterWksp = r"D:\data\rasters.gdb"
inPnts = r"D:\data\fgdb.gdb\randPnts"

arcpy.CheckOutExtension("Spatial")
arcpy.env.workspace = inRasterWksp

#create a list of rasters (GRID only) with "-b" in the name
rasters = arcpy.ListRasters("*_b*","")

#run tool with all rasters in the list accepting default field names
result = arcpy.sa.ExtractMultiValuesToPoints(inPnts,rasters)



Good luck. I hope this helps.
-Ryan


No one ever replied, so I will....Thank you!  This script served excellently as a solution to the problem.
0 Kudos