I have 1000 of raster file for which I am trying to extract multi values to point in a loop so that I have a series of values for each coordinate.

Here I have one raster for each week, and I want to name the field accordingly in the point shapefile's attribute table while extracting the values.

How to supply the variable name in the command line shown below

arcpy.gp.ExtractMultiValuesToPoints_sa(path/to/pointshapefile,"raster_2012_1.tif 2012_1","NONE")

Above code line works fine when "raster_2012_1.tif" is open in window and "a specific name "2012_1" is to be assigned. However, in case of varying raster files in loop and varying field name variables are required to be assigned.

I tried to assign variables as follows,

arcpy.gp.ExtractMultiValuesToPoints_sa(path/to/pointshapefile, path/to/raster.tif field_name,"NONE")

Here I am updating field name in each loop, but it shows following error

Parsing error SyntaxError: invalid syntax (line 5)

where (line 5) is the shown code line.

I guess this problem must be occurring because of the number of arguments in the command. How to overcome this problem?

Edit: Sample code

import arcpy
shapefile = 'C:\Users\Administrator\Desktop\DSBShape\Point.shp'
tif = 'Raster.tif'
header = 'Header'
arcpy.gp.ExtractMultiValuesToPoints_sa(shapefile, tif header, "NONE")
  • Can you provide a code snippet (rather than just a line or two) that results in that error on line 5, and the full error message, please?
    – PolyGeo
    Apr 28, 2017 at 11:32
  • I have edited the code, please see.
    – dsbisht
    Apr 28, 2017 at 11:36
  • 1
    Try putting an r in front of your path.
    – PolyGeo
    Apr 28, 2017 at 11:38
  • Thanks but for shapefile it is not giving any error. I mean without putting r in the shapefile path it is working absolutely fine but for raster and field name it is creating problem. Please have a look into the complete script here dropbox.com/s/vs8aba52x8bpj95/Script.py?dl=0
    – dsbisht
    Apr 28, 2017 at 11:42
  • 1
    What are you trying to do with tif header in the last line? Is it not supposed to be a list, like this: [tif, header]
    – BERA
    Apr 28, 2017 at 12:16

1 Answer 1


I could solve this question,

Since ExtractMultiValuesToPoints_sa only takes two argument, I tried to supply the second argument after adding two strings i.e., first the name of raster file and 2nd name of variable header with a blank save in between and it worked.

import arcpy
shapefile = 'C:\Users\Administrator\Desktop\DSBShape\Point.shp'
tif = 'Raster.tif'
header = 'Header'
arcpy.gp.ExtractMultiValuesToPoints_sa(shapefile, tif + ' ' + header, "NONE")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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