Is there where I can clip a raster with another raster by selecting specific cell value defined?

For example, I want to perform the clip operation using raster "A" as input and using raster "X1" as a clip raster where only interested on cell value = 1 in raster "X1". I have time series of rasters i.e. X1, X2, X3 and want to save the clip results with prefix from clip raster.

Is there way to perform this operation using ArcGIS 10.2 and python?

closed as off-topic by PolyGeo Jan 4 '18 at 4:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.


you can do this with map algebra. Note that "clipping" a raster is not like clipping a vector in the sense that a raster is always a matrix (therefore always rectangular) but you can set values to "NoData"

here is a code sample:

import arcpy
from arcpy.sa import *

# Set the current workspace
arcpy.env.workspace = "your/workspace"
#loop on all grids in workspace, using wildcard and raster type as option
for eachraster in arcpy.ListRasters("X*", "TIF"):
  outCon = Con(eachraster==1, Raster("A")) #if value of raster "A" equals 1, then use value of "eachraster", else NoData

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