I have a polygon shapefile (Vesijärvi lake). The lake has many islands, bays and inlets. When I look at the attribute table, there are actually two adjacent features: Northern lake and southern lake.

I have a pre-defined rectangular area of interest with the min x, max x, min y, max y in ETRS-TM35 FIN projected coordinates. The area of interest overlaps with the both parts of the lake.

I also have a pre-defined raster cell size (10 meters)

My task is: Create a .tif raster file, where 'water' cells (inside the lake) have a value of 1 and 'non-water' cells (outside of lake) have a value of 'no data'.

I know that in ArcGIS you can use a 'Feature to Raster' tool, but I don't have ArcGIS. I'm trying to use an open-source GIS, preferably QGIS. In QGIS, I found a tool called 'Rasterize' but I cannot set the minimum x, maximum x, minimum y, maximum y, cellsize and the lake polygon mask. There is a 'Horizontal' and 'Vertical' expression but any combination of numbers gives me an expression is not correct error.

Any help with using the QGIS rasterize tool (or a similar free vector-to-raster tool) for converting a polygon shapefile to a raster with the predefined extent, cellsize and mask would be appreciated.


You could add a field to the lake shapefile called "value", and populate it with the value 1. enter image description here

In your Rasterize tool, set the value field to "value", and create your raster. enter image description here

Then just clip the raster using your min/max x & y values using the Clipper tool? Raster -> Extraction -> Clipper
enter image description here

The output will be a clipped raster with 1 values for water (white) and 0 for non-water (black).

enter image description here

  • This is a good explanation. I wasn't aware of the clipper tool. In my case, I also had to choose "Raster resolution in map units per pixel" and set it to 10 because I require the cell size to be exactly 10 meters. Fortunately my clip rectangle is completely inside the clipped raster, and so the solution with Rasterize and Clipper works nicely. – jirikadlec2 Feb 27 '14 at 17:17

Actually I found an alternative solution to my problem using R. Here is my sample code. In the sample code, xmn, xmx, ymn, ymx are the coordinates of the pre-defined extent. "LAKE_ID" is the attribute with value equal to 1 for all polygons.


ymn <- 6758000
ymx <- 6766000
xmn <- 422000
xmx <- 429000
cellsize <- 10

lake <- readOGR(getwd(),"lake")
e <- extent(xmn, xmx, ymn, ymx)
r <- raster(e)
r <- rasterize(lake, field="LAKE_ID", r)

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.