The parameter type is "Analysis Cell Size".For example:
A = cell_Size.valueAsText
A is "C:\Temp\fgdb.gdb\ASAS"
Although, A apparently is a string, you can use A as cellsize in different tools! but can not get the numeric cell size.
ok... it is a filename, which you make into a raster, then get its cell size... I think this is similar to previous issues you were having with what is returned by parameters.
Thank you Dan,
In my program, I need the cell size numeric value for a bunch of calculations, before generating the raster. I was thinking about making a virtual raster just to get the size. It is possible but it is weird.
As Dan mentions, when you have a name of a raster as cell size, it means that that raster exists. It references an existing raster and the cell size should be obtained from that raster. You can convert in into a raster object (as Dan mentioned) and access the meanCellHeight and meanCellWidth properties:
import arcpy def main(): print GetCellSize('5') print GetCellSize('1.234') print GetCellSize(r'C:\GeoNet\ModRutaEscombro\gdb\ModRutaEscombros.gdb\CostDist') def GetCellSize(user_cell_size): try: # parse to double cell_size = float(user_cell_size) except: # not a numeric value, maybe a reference to an existing raster try: raster = arcpy.Raster(user_cell_size) cell_size = (raster.meanCellHeight + raster.meanCellWidth) / 2.0 except: cell_size = None return cell_size if __name__ == '__main__': main()
This will yield in my case:
5.0 1.234 47.0
As I said, when you are using "Analysis Cell Size" as an input data for python toolbox, you can enter number or pick a raster and "Feature class".
in the case of "Feature class", the cell size would be layer extent / 250 (Ersi's default)
Your solution is working for raster and number, however the problem still exists for "Feature class"
There is no cell size for feature classes.
If you want to convert a featureclass to a raster, then you have to specify one manually or select an existing raster.
It is as designed.
Agree, but when you use the ArcGIS toolbox for example Convert point to raster. For cell size you can just pick Raster. however, when you use "Analysis Cell Size" in your tool which exactly has the same interface of cell size in Convert point to raster tool, you can pick both raster and feature!
Not in my ArcMap 10.5 or ArcGIS PRO 1.4.1... point to raster will not even show me featureclasses or shapefiles as a selection option... only rasters, or specify one manually