| | 2813 | |
| | 2814 | # Public method: ArcGISRaster.ExtractByMask |
| | 2815 | |
| | 2816 | AddMethodMetadata(ArcGISRaster.ExtractByMask, |
| | 2817 | shortDescription=_(u'Extracts the cells of a raster that correspond to the areas defined by a mask.'), |
| | 2818 | longDescription=_( |
| | 2819 | u"""This tool just calls the ArcGIS Spatial Analyst's Extract By Mask |
| | 2820 | tool. It only exists so that we can easily create a batched version of |
| | 2821 | that 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 | |
| | 2828 | CopyArgumentMetadata(ArcGISRaster.Copy, u'cls', ArcGISRaster.ExtractByMask, u'cls') |
| | 2829 | |
| | 2830 | AddArgumentMetadata(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 | |
| | 2835 | AddArgumentMetadata(ArcGISRaster.ExtractByMask, u'mask', |
| | 2836 | typeMetadata=ArcGISGeoDatasetTypeMetadata(mustExist=True), |
| | 2837 | description=_( |
| | 2838 | u"""Input mask data defining areas to extract. |
| | 2839 | |
| | 2840 | This is a raster or feature dataset. |
| | 2841 | |
| | 2842 | When the input mask data is a raster, NoData cells on the mask will be |
| | 2843 | assigned NoData values on the output raster."""), |
| | 2844 | arcGISDisplayName=_(u'Input raster or feature mask data')) |
| | 2845 | |
| | 2846 | AddArgumentMetadata(ArcGISRaster.ExtractByMask, u'outputRaster', |
| | 2847 | typeMetadata=ArcGISRasterTypeMetadata(mustBeDifferentThanArguments=[u'inputRaster', u'mask'], deleteIfParameterIsTrue=u'overwriteExisting', createParentDirectories=True), |
| | 2848 | description=_( |
| | 2849 | u"""The output raster containing the cell values extracted from the |
| | 2850 | input raster. |
| | 2851 | |
| | 2852 | If this path refers to the file system, missing directories in the |
| | 2853 | path will be created if they do not exist."""), |
| | 2854 | direction=u'Output', |
| | 2855 | arcGISDisplayName=_(u'Output raster')) |
| | 3334 | BatchProcessing.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=[_( |
| | 3342 | u"""%s output rasters to receive the cell values extracted from the |
| | 3343 | input rasters. |
| | 3344 | |
| | 3345 | If these paths refers to the file system, missing directories in the |
| | 3346 | paths will be created if they do not exist.""")], |
| | 3347 | outputParamExpressionDescriptions=[ |
| | 3348 | u"""Python expression used to calculate the absolute path of an output |
| | 3349 | raster. The expression may be any Python statement appropriate |
| | 3350 | for passing to the eval function and must return a Unicode string. The |
| | 3351 | expression 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 | |
| | 3361 | The default expression:: |
| | 3362 | |
| | 3363 | os.path.join(outputWorkspace, inputRaster[len(workspaceToSearch)+1:]) |
| | 3364 | |
| | 3365 | stores the output rasters in the output workspace at the same relative |
| | 3366 | location as the input rasteres appear in the workspace to search. The |
| | 3367 | output raster path is calculated by stripping the workspace to search |
| | 3368 | from the input raster path and replacing it with the output workspace. |
| | 3369 | |
| | 3370 | For more information on Python syntax, please see the `Python |
| | 3371 | documentation <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 | |