I'm trying to reclassify only a certain part of a raster...not the entire raster. Here's the problem. I have a LULC raster of the entire US. There are some issues with the raster that I want to fix, namely some cells that should be water are classified as wetlands. These are mainly off the coast, not inland. However, some cells that are classified as wetlands should really be wetlands (mainly inland) and I don't want these to change. I plan on using a ZIP Code boundary file to determine which cells are considered "off the coast" and which ones are not. I have access to ArcGIS 10.1 and R with the appropriate raster packages I need so a solution in either software would be fine. Can anyone help me figure this out?
If I understand well, you have one class that needs to be changed only if it is located off the coast
So what you need to do is convert your ZIP code boundaries to raster (feature to raster): this will produce a raster that is Null (NoData) where you are not on inland.
Then apply a conditional statement in order to change your wetland values. In the raster calculator, this would look like this :
Con( IsNull("MyZIPraster") AND ("LULCraster"==wetland_value) , water_value , "LULCraster" )
where wetland_value and water_value are integer values of your class
Here is R solution: I used this post and edited it a little
library (raster) # use state bounds from gadm website: # us = shapefile("USA_adm1.shp") us <- getData("GADM", country="USA", level=1) # extract states (need to uppercase everything) nestates <- c("Maine", "Vermont", "Massachusetts", "New Hampshire" ,"Connecticut", "Rhode Island","New York","Pennsylvania", "New Jersey", "Maryland", "Delaware", "Virginia", "West Virginia") ne = us[match(toupper(nestates),toupper(us$NAME_1)),] # create a random raster over the space: r = raster(xmn=-85,xmx=-65,ymn=36,ymx=48,nrow=100,ncol=100) r=runif(100*100) # plot it with the boundaries we want to clip against: plot(r) plot(ne,add=TRUE) # now use the mask function rr <- mask(r, ne) # classification of masked cells rr <- ifelse(rr>0.5,1,0) # add classification to the original file r@data@values[!is.na(rr@data@values)] <- rr@data@values[!is.na(rr@data@values)] # plot, and overlay: plot(r);plot(ne,add=TRUE)