Select to view content in your preferred language

Extract By Mask - Image Analysis

3257
8
03-16-2012 08:08 AM
JohanSmith
Emerging Contributor
I am trying to extract information from a Raster Dataset that does not intersect with a feature dataset over the Gulf of Mexico. [ATTACH=CONFIG]12774[/ATTACH]

Both shapefile and raster are in the same projection. I have attempted to do this using the Mask function in Image Analysis however this does not extract any information. Rather it leaves an empty raster of 40mb in size (no attribute table) and exporting that dataset does nothing. I am wondering if the high resolution coastline is too complicated? Does anyone have another method to extract information outside of the polygon? IMO it is strange that vector data has erase and intersect functions but raster datasets have extract by mask but no erase equivalent.

J
0 Kudos
8 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Johan,

You have a couple options.

1.  You can convert your raster to a Mosaic Dataset.  With Mosaic Datasets you have the ability to apply functions.  One of the functions being 'Clip'.  The clip function allows you to clip based on a feature class with two option types:  Inside or Outside. 

Inside = pixels intersected by the feature class are removed
Outside = only pixels intersected by the feature class are retained

OR

2.  Create a new integer field in your raster dataset and set it to a value of one.  Convert the raster to a polygon based on the new field so that you get an output of one polygon.  Next, use the 'Erase' tool to remove the area you want excluded from your raster dataset.  Finally, use the new output from the Erase tool as the Mask area in the Extract by Mask tool.
0 Kudos
curtvprice
MVP Esteemed Contributor
Okay, I'll jump in.

You probably will have better luck if you convert your land area polygon to raster first using Polygon To Raster. This gives you more control and also is more likely to succeed with your complex polygon feature.

1. Set the output Coordinate system to your output raster "myraster"
2. Set extent to your raster dataset (or smaller area if you want), set snap and cell size to your raster dataset
3. Run Polygon To Raster, this will make a raster ("mask1") with NoData outside. Take a good look at "mask1" and make sure it's what you want, at this point you can go back to the Results and rerun Polygon To Raster until you have it just right.
4. Try either (both approaches require a Spatial Analyst license):
--  a. Reclassify "mask1" to remap "value cells" to NoData ("mask2") and NoData cells to 1
--  b. Extract By Mask with "myraster" and the mask dataset "mask2"
or,
--  Map algebra tool: Con(IsNull("mask1"),"myraster")
(in English: for each cell, if "mask1" is NoData, output value of "myraster")

With map algebra you can build some pretty complex processing that runs very efficiently compared to doing it with the equivalent tools one-by-one. (After all, "raster is faster, but vector is correcter".)

Happy Saturday!
0 Kudos
JohanL
by
Deactivated User
Could make a shapefile of the entire extent of the raster dataset and erase by the original shapefile to create a shapefile of the ocean regions.
0 Kudos
KelseyKaszas1
Deactivated User
I am having the same problem as Johan. I created 4 different viewsheds based on a DEM and variations of the same point data. I am trying to use a county polygon as a mask to extract the corresponding viewshed data. The weird part is that extract by mask worked perfectly well for 2 out of the 4 viewshed raster layers. The extract by mask fails everytime for the other two, I've tried restarting arc, re-creating the viewsheds, starting a new .mxd, converting the county polygon to raster and more. I really need the attribute table for the masked output to run stats.
0 Kudos
curtvprice
MVP Esteemed Contributor
Extract by mask worked perfectly well for 2 out of the 4 viewshed raster layers. The extract by mask fails everytime for the other two


There is a recently entered NIM on this, the workaround is to use the Clip_management tool.

NIM078864 The Extract by Mask tool returns a 99998 error when clipping certain rasters.

If that doesn't work, just a shot in the dark, if your scratch workspace is a folder, there is a known limit when the COUNT field hits 2.1 billion cells. You may have better luck if your scratch workspace is a file gdb.
0 Kudos
KelseyKaszas1
Deactivated User
There is a recently entered NIM on this, the workaround is to use the Clip_management tool.

NIM078864 The Extract by Mask tool returns a 99998 error when clipping certain rasters.



Curtis,

The link that you posted is not functioning for me, there is a glitch in the system because every time I click on the link it takes me to the esri Global login page, I attempt to login (even though I'm already logged in) and it just returns me to that same login page. I tried googling the NIM but nothing comes up either.

I already tried using the clip management tool, the problem is that it does not create an attribute table and I need the breakdown of pixel counts to run stats.

I'm not sure if the folder output is the issue because the extract by mask worked on the 1st and 3rd rasters and not on the 2nd and 4th. The rasters that I'm working with are small as well.
0 Kudos
curtvprice
MVP Esteemed Contributor
The link that you posted is not functioning for me


It is apparent to me that some NIMs are not visible to all.  I'm a beta tester, and have right-to-call support, so I may be able to access more NIMs than you do. The important thing is the NIM number, which is helpful when talking to Esri support.

I already tried using the clip management tool, the problem is that it does not create an attribute table and I need the breakdown of pixel counts to run stats.


If the raster is not integer, integerize it, then use the Build Raster Attribute table tool to build a RAT. Then  you'll have your count values. You can join any extra raster attributes from the source (if needed) using the Join Field tool.

Hope that helps.
0 Kudos
KelseyKaszas1
Deactivated User
Thanks Curtis!

The int tool worked perfectly. I did not need to use RAT tool, the Int tool added an attribute table.
0 Kudos