AnsweredAssumed Answered

Problem to add an input raster in a tool

Question asked by PaulBonnard on Jun 8, 2018
Latest reply on Jun 8, 2018 by PaulBonnard

Hi everyone, i am making a tool for arcgis. It is useful to replace the data of a raster by the weights that a user would give.


So to do this, i have to use my raster as an array that the module numpy supports very well. 

I tried with an array that i made and it works pretty good.


here is my code with the array and after this, the raster.




My problem is to import a raster as an input parameter, in my tool i have chosen the type "raster dataset" but it gives me this error. 

Exécution de : RasterExpert D:\Documents\bonnard\Travail\rasters_tests\ASCII\fs_ep_calage.asc "4 5 3 8 5 6 1 2"
Heure de début : Fri Jun 08 13:56:54 2018
Exécution du script RasterExpert...
Failed script RasterExpert...

Traceback (most recent call last):
File "C:\Users\bonnard\Desktop\Multi-critere\", line 5, in <module>
raster = arcpy.RasterToNumPyArray(raster)
File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\", line 2275, in RasterToNumPyArray
return _RasterToNumPyArray(*args, **kwargs)
TypeError: Argument in_raster\xa0: une instance de raster ou un nom de chemin sont attendus.


The TypeError means that python is looking for a path, if i give it directly in the script, in the function RasterToNumPyArray() it works.


However i want to give the path in the tool  


Like this ->


Do you have any idea ?