How do I adjust my script to accept a raster with a filename like the example below when used as a tool in ArcGIS with MulitValue set to Yes?
"008. STUDY AREA MAP_rectified_NAD83_Z12.tif"
With files named in the same way as above the script works in python with two rasters separated with a semi-colon(;).
It also works as a tool when the input parameter (Raster Dataset) has MultiValue set to no.
If I use input file with more conventional names (just numbers and letters) the MultiValue option works correctly.
However, with MultiValue set to yes it fails at the first GetRasterProperties_management task with:
ERROR 000865: [filepath\filename] does not exist
Unfortunately it is not possible to rename the files. Script below;
ScannedMaps = r'C:\ArcGIS\GeoRefCentrepoint\Data\010. STUDY AREA MAP1_rectified_NAD83_Z12.tif;C:\ArcGIS\GeoRefCentrepoint\Data\009. STUDY AREA MAP2_rectified_NAD83_Z12.tif'
for image in ScannedMaps.split(;):
print 'Starting: ',image
arcpy.AddMessage('Starting: '+image)
#Capture extent of georeferenced scanned map
MaxX = float(arcpy.GetRasterProperties_management(image,"RIGHT").getOutput(0))
MinX = float(arcpy.GetRasterProperties_management(image,"LEFT").getOutput(0))
MaxY = float(arcpy.GetRasterProperties_management(image,"TOP").getOutput(0))
MinY = float(arcpy.GetRasterProperties_management(image,"BOTTOM").getOutput(0))
print '- Extent captured'
arcpy.AddMessage('- Extent captured')
#Calculate centre point
centreX = (MaxX + MinX)/2
centreY = (MaxY + MinY)/2
print '- Centre point calculated'
arcpy.AddMessage('- Centre point calculated')
#Add centre point to feature, change file path, populate fields
NewFilePath = image.replace('S:','\\\UNCNAME\FOLDER\SUBFOLDER')
FileName = os.path.basename(image).split('.')[0]
NewRow = [(FileName, NewFilePath, KeyWords, (centreX,centreY))]
cursor = arcpy.da.InsertCursor(Feature,['DOCUMENT_NAME','URL','KEY_WORDS','SHAPE@XY'])
print '- Attributes created'
arcpy.AddMessage('- Attributes created')
for data in NewRow:
cursor.insertRow(data)
print '- File:',FileName,'added successfully\n'
arcpy.AddMessage('- File '+FileName+' added successfully')
del cursor
print 'Complete'
Update -
Output of when the script runs successfully from in PythonWin, included print ScannedMaps statement as requested:
Starting tool:
ScannedMaps = C:\ArcGIS\GeoRefCentrepoint\Data\010. MAP_rectified_NAD83_Z12.tif;C:\ArcGIS\GeoRefCentrepoint\Data\009. MAP_rectified_NAD83_Z12.tif
Starting: C:\ArcGIS\GeoRefCentrepoint\Data\010. MAP_rectified_NAD83_Z12.tif
- Extent captured
- Centre point calculated
- Attributes created
- File: 010 added successfully
ScannedMaps = C:\ArcGIS\GeoRefCentrepoint\Data\010. MAP_rectified_NAD83_Z12.tif;C:\ArcGIS\GeoRefCentrepoint\Data\009. MAP_rectified_NAD83_Z12.tif
Starting: C:\ArcGIS\GeoRefCentrepoint\Data\009. MAP_rectified_NAD83_Z12.tif
- Extent captured
- Centre point calculated
- Attributes created
- File: 009 added successfully
Complete
ScannedMaps
set to? Have you reviewed previous occurrences of this error: gis.stackexchange.com/questions/tagged/error-000865print ScannedMaps
line to "capture" whatScannedMaps
is set to for one occasion when you see this, and include a manual setting of that in your code snippet, please?