Hi,
I'm using the Conversion > Polygon to Raster tool in ArcMap and it is working well.
I tried to do a Python script to use this but with a large amount of files, but it says that the tool is not licenced.
Is it possible that some tools are available in ArcMap but not with ArcPy ?
Thanks
always go to the help topic for tools Polygon to Raster—Help | ArcGIS for Desktop
licensing requirements are listed at the bottom, so either you aren't licensed, or in this case, perhaps you don't have the appropriate extension toggled on in the Customize, Extensions menu option
Dan,
For working with extensions in ArcPy, would it be good to always start the scripts off with :
import arcpy if arcpy.CheckExtension("3D") == "Available": arcpy.CheckOutExtension("3D") else: print "3D Analyst license is unavailable"
Or does that mess things up if the license is already checked on in the local desktop ArcMap?
Not if you have it and are working in a single user environment and not one of those share-sy ones.
Accessing licenses and extensions in Python—Help | ArcGIS for Desktop
The setting of the product and extensions is only necessary within stand-alone scripts. If you are running tools from the Python window or using script tools, the product is already set from within the application, and the active extensions are based on the Extensions dialog box.
I never find any point in checking and getting a nice message, I would rather it fail and a real error message be thrown.
Thanks for your answers !
Adrian, I added your code to my script and now it's working ! My extensions were always checked in ArcMap (both Spatial and 3D analyst) but it wasn't working. Now with these 4 lines it works ! Thanks so much!
The setting of the product and extensions is only necessary within stand-alone scripts. If you are running tools from the Python window or using script tools, the product is already set from within the application, and the active extensions are based on the Extensions dialog box.
I would say "stand-alone scripts and or custom-tools from these stand-alone scripts". I find it is always better to check it out (and in at the end, if you want to keep it need) for my custom tools. In theory, the tools you write should be able to move to other machines, setups and license manager (concurrent or single-use), so better to check it out if needed for your process. I'm not sure if the second sentence is correct or not (haven't tested). It may be, assuming a license is available, otherwise you would still get an error, in my opinion.
Adrian Welsh does a nicer user interface then I use....I just do the checkout since you will still get an error if no licenses/seats are available (lazy coding on my part I guess). And no, it does not mess up what is already checked out as far as I can tell.
if arcpy.CheckExtension("3D") == "Available": arcpy.CheckOutExtension("3D") else: print "3D Analyst license is unavailable"
As a standalone script, I don't even bother checking since people should read the docs before running anything