GeoEco.ArcGIS.GeoprocessorManager.InitializeGeoprocessor
- classmethod GeoprocessorManager.InitializeGeoprocessor()
Initializes the ArcGIS geoprocessor so that the GeoEco package can access ArcGIS functionality.
It is usually not necessary for methods within GeoEco to call
InitializeGeoprocessor()directly. The usual pattern for implementing a GeoEco method that needs to access ArcGIS is to define aMethodMetadatafor the method with the dependencies argument set to alistcontaining anArcGISDependency. Then, as usual for methods that define aMethodMetadata, the method callsValidateMethodInvocation()as its first line of code, which initializes theArcGISDependency, which in turn callsInitializeGeoprocessor(). The method can then useGetWrappedGeoprocessor()to get the geoprocessor instance and access ArcGIS:from GeoEco.ArcGIS import GeoprocessorManager class MyClass(object): @classmethod def MyMethodThatAccessesArcGIS(cls): self.__doc__.Obj.ValidateMethodInvocation() # ValidateMethodInvocation() initialized the ArcGISDependency(), # which called InitializeGeoprocessor() for us. We can now just call # GetWrappedGeoprocessor(). gp = GeoprocessorManager.GetWrappedGeoprocessor() gp.XXXXX(...) # Call some geoprocessor tool or function
When using the
GeoprocessorManagerfrom a stand-alone script or other contexts that do not involve initializing aArcGISDependency, it is necessary to callInitializeGeoprocessor()explicitly:from GeoEco.ArcGIS import GeoprocessorManager def MyStandAloneScript(): GeoprocessorManager.InitializeGeoprocessor() gp = GeoprocessorManager.GetWrappedGeoprocessor() gp.XXXXX(...) # Call some geoprocessor tool or function if __name__ == '__main__': MyStandAloneScript()
If you do not want to use
InitializeGeoprocessor()to instantiate the geoprocessor, you should create it yourself and callSetGeoprocessor().GeoprocessorManagerwill cache a reference to your geoprocessor and use it instead.GeoprocessorManagermaintains a single, interpreter-wide geoprocessor shared by all of its callers.There is no harm in calling
InitializeGeoprocessor()after it orSetGeoprocessor()has already been called. IfGeoprocessorManageralready has a geoprocessor,InitializeGeoprocessor()will do nothing. If you need to replace the geoprocessor thatGeoprocessorManageris using, you can callSetGeoprocessor().