Changeset 868

Show
Ignore:
Timestamp:
12/21/11 10:19:09 (17 months ago)
Author:
jjr8
Message:

* Incremented build number.
* Added batched Extract By Mask tool.

Location:
MGET/Branches/Jason/PythonPackage/src/GeoEco
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • MGET/Branches/Jason/PythonPackage/src/GeoEco/DataManagement/ArcGISRasters.py

    r855 r868  
    2727import sys 
    2828 
    29 from GeoEco.ArcGIS import GeoprocessorManager, ArcGISDependency 
     29from GeoEco.ArcGIS import GeoprocessorManager, ArcGISDependency, ArcGISExtensionDependency 
    3030from GeoEco.DatabaseAccess import DatabaseConnection, InsertCursor 
    3131from GeoEco.DatabaseAccess.ArcGIS import ArcGIS91DatabaseConnection 
     
    15671567 
    15681568    @classmethod 
     1569    def ExtractByMask(cls, inputRaster, mask, outputRaster, overwriteExisting=False): 
     1570        cls.__doc__.Obj.ValidateMethodInvocation() 
     1571        try: 
     1572            gp = GeoprocessorManager.GetWrappedGeoprocessor() 
     1573            gp.ExtractByMask_sa(inputRaster, mask, outputRaster) 
     1574        except: 
     1575            Logger.LogExceptionAsError() 
     1576            raise 
     1577 
     1578    @classmethod 
    15691579    def ProjectClipAndOrExecuteMapAlgebra(cls, inputRaster, outputRaster, projectedCoordinateSystem=None, geographicTransformation=None, resamplingTechnique=None, projectedCellSize=None, registrationPoint=None, clippingDataset=None, clippingRectangle=None, mapAlgebraExpression=None, buildPyramids=False, overwriteExisting=False): 
    15701580        cls.__doc__.Obj.ValidateMethodInvocation() 
     
    28012811may be different than what ArcGIS used when it created the 
    28022812raster.""")) 
     2813 
     2814# Public method: ArcGISRaster.ExtractByMask 
     2815 
     2816AddMethodMetadata(ArcGISRaster.ExtractByMask, 
     2817    shortDescription=_(u'Extracts the cells of a raster that correspond to the areas defined by a mask.'), 
     2818    longDescription=_( 
     2819u"""This tool just calls the ArcGIS Spatial Analyst's Extract By Mask 
     2820tool. It only exists so that we can easily create a batched version of 
     2821that tool."""), 
     2822    isExposedToPythonCallers=True, 
     2823    isExposedByCOM=True, 
     2824    isExposedAsArcGISTool=False, 
     2825    arcGISToolCategory=_(u'Spatial Analysis\\Project, Clip and/or Execute Map Algebra'), 
     2826    dependencies=[ArcGISDependency(9, 1), ArcGISExtensionDependency(u'spatial')]) 
     2827 
     2828CopyArgumentMetadata(ArcGISRaster.Copy, u'cls', ArcGISRaster.ExtractByMask, u'cls') 
     2829 
     2830AddArgumentMetadata(ArcGISRaster.ExtractByMask, u'inputRaster', 
     2831    typeMetadata=ArcGISRasterLayerTypeMetadata(mustExist=True), 
     2832    description=_(u'The input raster from which cells will be extracted.'), 
     2833    arcGISDisplayName=_(u'Input raster')) 
     2834 
     2835AddArgumentMetadata(ArcGISRaster.ExtractByMask, u'mask', 
     2836    typeMetadata=ArcGISGeoDatasetTypeMetadata(mustExist=True), 
     2837    description=_( 
     2838u"""Input mask data defining areas to extract. 
     2839 
     2840This is a raster or feature dataset. 
     2841 
     2842When the input mask data is a raster, NoData cells on the mask will be 
     2843assigned NoData values on the output raster."""), 
     2844    arcGISDisplayName=_(u'Input raster or feature mask data')) 
     2845 
     2846AddArgumentMetadata(ArcGISRaster.ExtractByMask, u'outputRaster', 
     2847    typeMetadata=ArcGISRasterTypeMetadata(mustBeDifferentThanArguments=[u'inputRaster', u'mask'], deleteIfParameterIsTrue=u'overwriteExisting', createParentDirectories=True), 
     2848    description=_( 
     2849u"""The output raster containing the cell values extracted from the 
     2850input raster. 
     2851 
     2852If this path refers to the file system, missing directories in the 
     2853path will be created if they do not exist."""), 
     2854    direction=u'Output', 
     2855    arcGISDisplayName=_(u'Output raster')) 
    28032856 
    28042857# Public method: ArcGISRaster.ProjectClipAndOrExecuteMapAlgebra 
     
    32793332    overwriteExistingDescription=_(u'If True and skipExisting is False, existing destination rasters will be overwritten.')) 
    32803333 
     3334BatchProcessing.GenerateForMethod(ArcGISRaster.ExtractByMask, 
     3335    inputParamNames=[u'inputRaster'], 
     3336    inputParamFieldArcGISDisplayNames=[_(u'Input raster field')], 
     3337    inputParamDescriptions=[_(u'%s input rasters.')], 
     3338    outputParamNames=[u'outputRaster'], 
     3339    outputParamFieldArcGISDisplayNames=[_(u'Output raster field')], 
     3340    outputParamExpressionArcGISDisplayNames=[_(u'Output raster Python expression')], 
     3341    outputParamDescriptions=[_( 
     3342u"""%s output rasters to receive the cell values extracted from the 
     3343input rasters. 
     3344 
     3345If these paths refers to the file system, missing directories in the 
     3346paths will be created if they do not exist.""")], 
     3347    outputParamExpressionDescriptions=[ 
     3348u"""Python expression used to calculate the absolute path of an output 
     3349raster. The expression may be any Python statement appropriate 
     3350for passing to the eval function and must return a Unicode string. The 
     3351expression may reference the following variables: 
     3352 
     3353* workspaceToSearch - the value provided for the workspace to search 
     3354  parameter 
     3355 
     3356* outputWorkspace - the value provided for the output workspace 
     3357  parameter 
     3358 
     3359* inputRaster - the absolute path to the input raster 
     3360 
     3361The default expression:: 
     3362 
     3363    os.path.join(outputWorkspace, inputRaster[len(workspaceToSearch)+1:]) 
     3364 
     3365stores the output rasters in the output workspace at the same relative 
     3366location as the input rasteres appear in the workspace to search. The 
     3367output raster path is calculated by stripping the workspace to search 
     3368from the input raster path and replacing it with the output workspace. 
     3369 
     3370For more information on Python syntax, please see the `Python 
     3371documentation <http://www.python.org/doc/>`_."""], 
     3372    outputParamDefaultExpressions=[u'os.path.join(outputWorkspace, inputRaster[len(workspaceToSearch)+1:])'], 
     3373    constantParamNames=[u'mask'], 
     3374    processListMethodName=u'ExtractByMaskList', 
     3375    processListMethodShortDescription=_(u'For each ArcGIS raster in a list, extracts the cells that correspond to the areas defined by a mask.'), 
     3376    processTableMethodName=u'ExtractByMaskTable', 
     3377    processTableMethodShortDescription=_(u'For each ArcGIS raster in a table, extracts the cells that correspond to the areas defined by a mask.'), 
     3378    processArcGISTableMethodName=u'ExtractByMaskArcGISTable', 
     3379    processArcGISTableMethodArcGISDisplayName=_(u'Extract By Mask for ArcGIS Rasters Listed in Table'), 
     3380    findAndProcessMethodName=u'FindAndExtractByMask', 
     3381    findAndProcessMethodArcGISDisplayName=u'Find ArcGIS Rasters and Extract By Mask', 
     3382    findAndProcessMethodShortDescription=_(u'Finds and rasters in an ArcGIS workspace and extracts the cells that correspond to the areas defined by a mask.'), 
     3383    findMethod=ArcGISRaster.FindAndCreateTable, 
     3384    findOutputFieldParams=[u'rasterField'], 
     3385    findAdditionalParams=[u'wildcard', u'searchTree', u'rasterType'], 
     3386    outputLocationTypeMetadata=ArcGISWorkspaceTypeMetadata(createParentDirectories=True), 
     3387    outputLocationParamDescription=_(u'Workspace to receive the output rasters.'), 
     3388    outputLocationParamArcGISDisplayName=_(u'Output workspace'), 
     3389    calculateFieldMethod=Field.CalculateField, 
     3390    calculateFieldExpressionParam=u'pythonExpression', 
     3391    calculateFieldAdditionalParams=[u'modulesToImport'], 
     3392    calculateFieldAdditionalParamsDefaults=[[u'os.path']], 
     3393    calculateFieldHiddenParams=[u'statementsToExecFirst', u'statementsToExecPerRow'], 
     3394    calculateFieldHiddenParamValues=[[u'import inspect\nf = inspect.currentframe()\ntry:\n    workspaceToSearch = f.f_back.f_back.f_back.f_back.f_back.f_locals[\'inputWorkspace\']\n    outputWorkspace = f.f_back.f_back.f_back.f_back.f_back.f_locals[\'outputWorkspace\']\nfinally:\n    del f\n'], [u'inputRaster = row.inputRaster']], 
     3395    calculatedOutputsArcGISCategory=_(u'Output raster name options'), 
     3396    skipExistingDescription=_(u'If True, processing will be skipped for output rasters that already exist.'), 
     3397    overwriteExistingDescription=_(u'If True and skipExisting is False, existing output rasters will be overwritten.')) 
     3398 
    32813399BatchProcessing.GenerateForMethod(ArcGISRaster.ProjectClipAndOrExecuteMapAlgebra, 
    32823400    inputParamNames=[u'inputRaster'], 
  • MGET/Branches/Jason/PythonPackage/src/GeoEco/OceanographicAnalysis/Eddies.py

    r808 r868  
    633633    longDescription=_( 
    634634u"""Minimum area-to-perimeter ratio for eddy cores, normalized such 
    635 that a perfect sphere has the value 1. Eddy cores with ratios less 
     635that a perfect circle has the value 1. Eddy cores with ratios less 
    636636than this value will be ignored. 
    637637 
     
    641641    4 * pi * area / perimeter^2 
    642642 
    643 Under this formulation, a perfect sphere will have the value 1.0, a 
     643Under this formulation, a perfect circle will have the value 1.0, a 
    644644square, about 0.7854, and an equilateral triangle, about 0.6046. 
    645645 
  • MGET/Branches/Jason/PythonPackage/src/GeoEco/__init__.py

    r855 r868  
    1 __version__ = u'0.8a30' 
     1__version__ = u'0.8a31'