NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

How can I use gdal_rasterize to produce a (GeoTiff) raster mask from the polygons found in: (WGS84 Shapefile split-polygons)?

I have tried variations such as:

gdal_rasterize -l land_polygons -init 0 -b 1 -burn 255 -of gtiff -ts 2000 1000 land_polygons.shp land_polygons.tif

... but all I get is a raster filled with 0.

asked 13 Nov '15, 19:59

rosstrafford's gravatar image

accept rate: 0%

I ran this with the simplified_land_polygons shapefile (no need to go super detailed if your output file is just 2k x 1k pixels):

gdal_rasterize -l simplified_land_polygons -burn 255 -of gtiff -ts 2000 1000 simplified_land_polygons.shp out.tiff

and it worked nicely. Note the omission of your "-b 1" which gave an error message for me.

permanent link

answered 13 Nov '15, 22:10

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%


Thanks Frederik, I'll give that a try shortly. Yes, I did have to get rid of the "-b 1" as well.

This should get me somewhere for now. However, I would like to do a bit better.

It's likely that the "simplified" polygons are considerably lower resolution (only 23 MB) than the ones I was trying to use. In the end, I want very detailed resolution - I will want to carve out tiles that are a few degrees wide, and ultimately want to get down below 100m resolution, so this dataset might not do the trick.

I also see that the simplified polygons are delivered in Mercator rather that WGS84 (lat/lon). I'd like to get as far north (and south) as I can, so the WGS84 sets would be preferable. Anyway, there are 3 other datasets I could try, so I'll cross my fingers.

I'll re-post back here to indicate which datasets work and don't work.

(14 Nov '15, 05:26) rosstrafford

Hi Frederik.

Using the simplified polygons also does NOT work for me.

Maybe I should question my gdal/ogr library. I am using 1.11.1 built from source on SuSE 12.2. What version are you using?

(15 Nov '15, 15:34) rosstrafford

1.10.1 on Ubuntu.

(15 Nov '15, 15:38) Frederik Ramm ♦

Do you have any other suggestions?

What I am really shooting for is to use it as a mask for DEM topography and bathymetry (to display one or the other in any given pixel). I need to get this big shapefile into 10 degree square tiles, and use these as a mask. Keeping it as vector, may actually be better (to get the resolution I need with raster would be immensely huge for the whole world), but I think that testing "inside vs outside" for each polygon will be seriously costly.

(16 Nov '15, 17:38) rosstrafford

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Nov '15, 19:59

question was seen: 4,790 times

last updated: 16 Nov '15, 17:38

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum