Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to perform IsNull function to a raster using PyScripter. This is the code I use:

import arcpy
import arcinfo
InRaster = "C:\\data\InRaster"
IsNullRa = "C:\\data\IsNullRa"
arcpy.gp.IsNull_sa(InRaster, IsNullRa)

In ArcGIS Python window, it works OK. However, in a different editor such as PyScripter I get this error:

ERROR 000824: The tool is not licensed. Failed to execute (IsNull).

I have ArcGIS 10.1 and do have spatial analyst. I tried installing Microsoft Visual C++ 2008 Redistributable Package (x64) from here but it did not work. Do you know how I can run IsNull outside of ArcGIS? Thanks.

share|improve this question
    
In addition to an answer to your specific question (see below), I think that the preferred syntax for the IsNull tool is IsNullRa = arcpy.IsNull(InRaster) –  Erica Jul 24 at 20:52
1  
Great! I had used ArcGIS Geo processing model builder to come up with the weird syntax I used! Your syntax is definitely easier. –  bikhaab Jul 24 at 20:58
    
That would actually be IsNullRa = arcpy.**sa**.IsNull(InRaster) –  csny490 Jul 24 at 22:35
    
Yes, good catch. Or include from arcpy.sa import * in the initial setup. –  Erica Jul 25 at 2:37

1 Answer 1

up vote 4 down vote accepted

To check out the extension outside of ArcGIS, add this line at the beginning of the script, after the import statements.

arcpy.CheckOutExtension("Spatial")
share|improve this answer
    
It totally works! I had thought that arcpy.CheckOutExtension("Spatial") is used just for checking whether you have "Spatial" extension. Well, it seems that it actually activates the extension for uses outside of ArcGIS. –  bikhaab Jul 24 at 20:56
    
Glad it solved your problem :) –  Erica Jul 24 at 20:57
2  
If you're outside of ArcMap yes you do need to activate extensions but also you should be deactivating the extensions as well when you're finished with them or you could end up holding onto an extension license with no process. To do this use arcpy.CheckInExtenstion. –  Michael Miles-Stimson Jul 24 at 23:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.