Raster Clipping

5028
11
02-17-2015 07:36 AM
MichaelBrown3
New Contributor II

So I have multiple rasters that I would like to clip to a single extent. All data is orthorectified geotiffs in the same projection. There is Identical pixel overlay. The extent I would like to clip the rasters to is where they all have data. Basically, I'm looking for the maximum area where they all have data so I can do time change analysis on the area. Now, I see where and how I can do this in arc tools, but I need a polygon shapefile in order to do so. I don't have the information to create a polygon with the boundaries I desire (where all rasters overlay).

 

     Question: Is there any way to clip multiple rasters to where they all overlay without the use of a polygon? And if there isnt, how can I clip this data with a polygon to obtain what I am after?

 

Thanks for your time.

 

- Michael -

0 Kudos
11 Replies
DarrenWiens2
MVP Honored Contributor

My main question for you is, are you trying to remove pixel values (e.g. '0') or NoData?

Depending on your data, it may be possible to mosaic the rasters together using either minimum or maximum as the mosaic operator, in order to identify the pixels where data exists for all rasters. For example, if you want to identify and remove all '0' pixels, then mosaicking with maximum would identify those where all rasters had '0', and vice versa if you want to remove '255' (or other max number). If you are trying to ignore NoData values, I believe they should automatically remove themselves from the mosaic. Once you have your mosaic, you should be able to convert to polygon for your clipping mask.

0 Kudos
ChrisDonohue__GISP
MVP Alum

I don't have the exact answer, but can throw out some thoughts.  It sounds like two things need to be figured out:

1.  When looking at all the raster datasets, what is the extent they all have data.

2.  Then raster clip to this extent, but without a polygon.

An Idea:

If you have the Spatial Analyst Extension, it may be possible to add the rasters together and come up with a raster that represents the extent of all data.  Be careful that when adding rasters that when a No Data pixel and a Data pixel are summed that the Data pixel predominates.  This raster addition process could be via Raster Calculator, or by a loop in Modelbuilder or Python.  Then use Raster Clip ArcGIS Help (10.2, 10.2.1, and 10.2.2) with the raster you derived as the clipping extent.  If you have many rasters, Modelbuilder or Python will come in handy to run through the clipping of all them.

Chris Donohue, GISP

0 Kudos
DarrenWiens2
MVP Honored Contributor

Just a small nit-pick, if you add NoData to Data in Raster Calculator, you will be left with NoData. You can get around it by using Con(IsNull("raster"), "otherraster", "raster") and setting the processing extent to the entire shared area.

ChrisDonohue__GISP
MVP Alum

I figured that might be an issue, which is why I included the warning.  Thanks for posting the code - I wasn't sure what the exact solution to get around that was.

Chris Donohue, GISP

0 Kudos
MichaelBrown3
New Contributor II

I want to do a combination of both responses. I want to ignore 0's in my data and extract the extent (whatever that may be) where all rasters have actual data.

Question 1). Will mosaicing work if all my rasters are imagery of the same location? I dont need to stitch them together, just remove the O's.

And a new question... Apparently one of my rasters dont line up exactly with the others. It is still ortho rectified, and a geotiff, but the pixels dont align with the others. Advice on aligning this raster with the others? Snap raster? Resample? I dont know

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

Hi Michael,

You could use the following workflow.

1) Use model builder to convert the rasters into simple polygons

     a) Use Iterate Raster.

     b) Reclassify the background value (e.g. 0) to NoData, while rest of the values (255 is the maximum value among all raster data, in my example) to 1.

     c) Convert the Raster to polygon.

2) Use intersect (Analysis) to get the common area of interest of all the polygons.

3)Use the above intersected polygon to intersect the rasters.

Thanks,

Jay



Think Location
MichaelBrown3
New Contributor II

Yes! Ok, the model builder is exactly what I want to do. I built the model as shown but I am getting the error...

" ERROR 000581: Invalid Parameters. Failed to execute (Reclassify). "

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

Could you send a snapshot of the reclassify tool in Modelbuilder



Think Location
0 Kudos
MichaelBrown3
New Contributor II

Alright, so I got this model to work beautifully (Tip-of-the-hat to Jayanta Poddar).

So ignore the error message I recently posted.

My next question is how to align the pixels exactly. The rasters are in the same format, projection, reference, etc... but the cell sizes differ + or - .005. Is there a way to align these slightly off rasters? My searches keep returning "snap raster" but I don't know how...

Question: How do I put rasters on the same grid? (I think is my question?)

- Michael -

0 Kudos