Keep the entire operation in raster, no need to convert to/from vector.
This uses ArcGIS 10 raster calculator syntax and assumes that your minimum distance is 50 "units" and your output landuse class is "234":
Con(InList("landuse",[22,23,24]) * EucDistance(Con("landuse" == 21,1), 50), 1)
This will give you a single value of 1 where landuse is 22,23 or 24 within 50 units of road (21) and NoData everywhere else. You can then combine that with your original landuse with something like:
Con(IsNull("near road raster"), "landuse", 234)
You could probably combine that into a single step, but I didn't try.
Note: ArcGIS <= 9.3x syntax will likely be different. For example, I remember that Workstation GRID and older Spatial Analyst syntax is "IN {22, 23,24}" instead of "InList(22,23,24)"
Edit: And you can do it in one hit with:
Con(IsNull(InList("landuse",[22,23,24]) * EucDistance(Con("landuse" == 21,1), 50)), "landuse",234)
You can use the aggregate
function in the raster
package to do this. For example, to produce a raster at half the resolution of the original, showing the proportion of cells covered with land class 1
:
aggregate(r, fact=2, fun=function(vals, na.rm) {
sum(vals==1, na.rm=na.rm)/length(vals)
})
To do this for all land classes:
cov_pct <- lapply(unique(r), function(land_class) {
aggregate(r, fact=2, fun=function(vals, na.rm) {
sum(vals==land_class, na.rm=na.rm)/length(vals)
})
})
Best Answer
As discovered in the comments, one row (value = 21) was selected before running Reclassify. The Reclassify tool only considered the selected row, therefore only reclassified those pixels where value = 21, to the new value, 2.
Edit: it may be worth noting that there is no mention of whether Reclassify respects selections in the help page. I would be interested to know if there is documentation regarding Reclassify's or Spatial Analyst's use of selections.