filter.list = ["Raster"] is Wrong?

1034
4
Jump to solution
05-09-2017 05:10 PM
MohammadrezaNikfal1
Occasional Contributor

I am trying to build a Python Toolbox, like in the following code snippet. However I got error because of the last line (Filter) . I have to filter the files because without the filter the output window shows all kind of data including Feature class.

    # First parameter  
    param1 = arcpy.Parameter(  
    displayName="Output Raster Dataset",  
    name="in_rasterdataset",  
    datatype=["Raster Dataset"],  
    parameterType="Required",  
    direction="Output ")  
    param1 .filter.list = ["Raster"]  ‍‍‍‍‍‍‍‍
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor

I reformatted your code. It does look like you have a syntax error, but maybe it is just a copy error.

If you want a python toolbox template, I suggest you try New > Python Toolbox or use the one in the help. 

The Python toolbox template—Help | ArcGIS Desktop 

Defining parameters in a Python toolbox—Help | ArcGIS Desktop 

Defining parameter data types in a Python toolbox—Help | ArcGIS Desktop 

The help has the keywords you want, for example, for datatype you probably want "GPRasterLayer" or "DERasterDataset", not "Raster". If there's only one, you should only specify the string, not a list.

If you get the datatype keyword correct, I don't think you need to define param.filter.list.

View solution in original post

0 Kudos
4 Replies
JimCousins
MVP Regular Contributor

Perhaps you need to use "Raster Dataset" instead of "Raster"?

Best Regards,

Jim

0 Kudos
MohammadrezaNikfal1
Occasional Contributor

I have already tried "Raster", "RASTER", "Raster Dataset" etc.

It does not work.

Thanks

0 Kudos
DanPatterson_Retired
MVP Emeritus

Well, your link goes to your training record from which nothing can be accessed.

Perhaps if you share the actual error message it might help and confirm that the space in line 8 after param1 and .filter is just a copying issue. 

0 Kudos
curtvprice
MVP Esteemed Contributor

I reformatted your code. It does look like you have a syntax error, but maybe it is just a copy error.

If you want a python toolbox template, I suggest you try New > Python Toolbox or use the one in the help. 

The Python toolbox template—Help | ArcGIS Desktop 

Defining parameters in a Python toolbox—Help | ArcGIS Desktop 

Defining parameter data types in a Python toolbox—Help | ArcGIS Desktop 

The help has the keywords you want, for example, for datatype you probably want "GPRasterLayer" or "DERasterDataset", not "Raster". If there's only one, you should only specify the string, not a list.

If you get the datatype keyword correct, I don't think you need to define param.filter.list.

0 Kudos