1

I have a raster layer and a polygon layer overlaying the raster. The thing is that I want to make a new raster as follows: 1) the extents of the new raster should be the same as the old raster. 2) The cells which are overlain by polygons should have a value of 1 and the parts which are not overlain by polygons, should have the value of zero.

enter image description here

  • 1
    Don't forget to take the Tour which is designed to introduce all users to this site and its protocols. If you are not using R, then please ask a new question, and specify the GIS software that you are using. – PolyGeo Jan 24 '18 at 5:11
3

You do not specify the software you are using, so I assume it is R. Here is how you can do it:

Some example data

library(raster)
pols <- shapefile(system.file("external/lux.shp", package="raster"))[1:3, ]
r <- raster(extent(pols), res=.01)

Solution

r <- rasterize(pols, r, field=1, background=0)
plot(r)
  • Thanks a lot. I forgot to say I'm using ArcGIS but I tried your advice in R and it worked :) – Arsalan Jan 24 '18 at 18:37

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.