How to erase raster from polygon

5491
5
02-02-2018 02:52 PM
AdrianRamanzin
New Contributor II

How do I delete cells from a raster based on an overlaying polygon layer?

There is a geoprocessing tool called Erase (Analysis) which I used to delete line features that fell within the boundaries of a polygon layer that I created. I cannot for the life of me figure out why esri could not make a geoproccesing tool that does the same thing for raster features. I'm hoping there is one and that I am just blind, but in case I'm not does anyone know of any work arounds?

0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

SetNull will do it  It is a good idea to pay attention to the cell size, extents and snap raster in the Environments section prior to doing any raster analysis.

AdrianRamanzin
New Contributor II

SetNull does not work. I have enclosed 3 images, the first is the raster, the second is the polygon, and the third is the result of running SetNull. When I run the SetNull it turns the original value range of 1.23 - -2.40 to -7.72e-006 - -2.40, which doesn't make sense.

0 Kudos
DanPatterson_Retired
MVP Emeritus
  • What were the extents of both files?
  • do they match?
  • When you converted the polygon to a raster, did you use the same cell size, extent and snap raster?
  • What was your nodata value?

If that isn't to your liking, you try the Con tools by using a 'Mask Raster'

http://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/con-.htm

AdrianRamanzin
New Contributor II

I figured out a way to do it. I tried using SetNull for quite a while with different SQL equations with con, and making sure the extents, snap raster, and cell sizes were all the same. In the end it just wasn't working. The old computer I'm using could be the reason why, or maybe its because I am working with data with lots of different projections since my data reaches so far up into the arctic, and sometimes things don't get defined properly without my seeing.

Eventually I just made a new polygon shapefile of the ocean area I wanted, and the surrounding land, and used that in the Extract by Mask tool. I had tried this before and it didn't work. I thought it might be because areas of no data existed in the mask layer where there was land and not ocean. This time though I made sure the cell size, extents, and snap rasters in environments were all set to the input raster I was trying to clip. Thankfully it finally worked.

Thanks for your help!

DanPatterson_Retired
MVP Emeritus

No problem, glad you got it figured out

0 Kudos