4

I have been wrestling with this for a while and couldn't find out how I can do this. I want each cell of a raster inside of a polygon boundary to have the value of the closest cell just outside of the polygon.

I think the closest answer was the one at this question, but I couldn't apply it!

My plan was:

  1. Use "Polygon to Raster" to change the polygon to a raster. The cells inside the polygon become 1 and the points outside of the polygon are nodata.
  2. Use Con(IsNull(Raster),0,NULL) and assign it to Raster2
  3. Add Raster1 and Raster2 to get nodata inside the polygon
  4. It should be easy from here with nodata inside the polygon. We just use "Euclidean Allocation" and it does the job.

I'm stuck at step 2 and get an error:

[SELECT * FROM VAT_Extent_RAS WHERE IsNull( "Value" )] Failed to execute (Con).

Do you have any thoughts? Is there an easier way to do this?

Update:

I'll try to summarize my progress here. I want to change all raster cells inside the polygon to "nodata" while the raster cells outside of the polygon remain the same. I used polygon to raster function first. This gives me a raster with 0 cell inside the polygon and "nodata" outside of the polygon. What do I do next?

6
  • 1
    What error? Please provide error message. Jul 1, 2014 at 0:38
  • [SELECT * FROM VAT_Extent_RAS WHERE IsNull( "Value" )] Failed to execute (Con).
    – ahoosh
    Jul 1, 2014 at 0:44
  • instead of Con(IsNull(Raster),0,NULL) try Con(IsNull(Raster),0) the NoData should be unstated. Sorry, I'm finding it a bit difficult to follow your process. Jul 1, 2014 at 0:59
  • Hi Michael! I erased that. The problem is the "IsNull" section. I get the same error when I use IsNull("Value"). I am not sure why it is.
    – ahoosh
    Jul 1, 2014 at 1:11
  • It's a raster conditional operator resources.arcgis.com/en/help/main/10.2/index.html#//… IsNull(Raster) true if the raster is null, false if the raster is not null. You can't use "Value" in there because that's a constant not a raster. Jul 1, 2014 at 1:14

1 Answer 1

5

The Euclidean Allocation tool can accept your polygon as input, but you are right you need to set the values inside the polygon to NoData for this tool to work, otherwise it will pick up the values that are already there.

First to feature to polygon, this will give values (any value, it doesn't matter, we're only interested in value or NoData) inside the polygon and NoData outside.

Now do IsNull on the polygon raster, this will give you a raster with 1 outside the polygon and 0 inside the polygon. Hereafter called IsNullRaster. This can be done in a single statement but I want to use it twice so it's worth persisting it to disc.

Con with the IsNullRaster: Con(IsNullRaster,ValueRaster) - now you have a raster that is null inside the polygon and contains values outside the polygon. I'll call this one ValueRasterHole. If this is giving you grief do something like Con(IsNullRaster,ValueRaster,255) and then use Set Raster Properties to enforce 255 as the nodata value.

Set your cell size, extent and snap raster to the ValueRaster and do Euclidean Allocation tool against the ValueRaster with the hole. This one is AllocatedRaster and will have values outside the polygon.

To merge the AllocatedRaster and the ValueRaster together use another Con with the IsNullRaster: Con(IsNullRaster,ValueRaster,AllocatedRaster) will fill in the hole in the polygon with the allocated raster.

6
  • Thanks for your thorough and complete solution. I used polygon to raster to make a raster from polygon. The values inside the polygon are zero. I guess the values outside of polygon are nodata (When I get the unique values just zero shows up and not nodata) Anyways, from here, I try to use IsNull function to get 0 inside and 1 outside of the polygon. I get this error: ERROR 010067: Error in executing grid expression. Failed to execute (IsNull). Do you have any idea where I'm messing it up?
    – ahoosh
    Jul 1, 2014 at 15:04
  • +1 -- but you might want to research SetNull because it will considerably streamline this workflow.
    – whuber
    Jul 1, 2014 at 16:04
  • I have the same problem with SetNull. It gives me an error. A friend just recommened me to check the data type in the raster. It's long data and IsNull or SetNull don't like long values. That might be the problem.
    – ahoosh
    Jul 1, 2014 at 16:12
  • I confirm that the problem was not using a integer base field when converting the polygon to raster.
    – ahoosh
    Jul 1, 2014 at 16:56
  • Now I am going to use Euclidean Allocation tool. I have a raster that has nodata inside the polygon and correct data outside the polygon. However, I cannot use Euclidean Allocation tool since it requires a source field. Although that is optional, it is forcing me to use something in the field and gives me error 000864 ("Source field: The input is not within the defined domain. ERROR 000889: Invalid field type"). Just a side note: When I right click on my raster, the "open attribute table" is off. Any suggestions? Thanks.
    – ahoosh
    Jul 1, 2014 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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