1

I have world oceans vector layer in .shp format. It looks like this.
Ocean vector
This vector has only one feature, which represents world ocean.
I need to create raster mask with 1 - ocean, and 0 - land.
When I try Rasterize, as output I have fully black raster image.
Then I have tried to create new numeric field
Fields and use this field for rasterizing, but QGIS doesn`t see this new field.
Rasterize

How can I solve my problem?

  • Could you add -ot BYTE in the gdal_translate box (by clicking on the pencil icon) and see if it changes? – Kazuhito Nov 22 '17 at 16:58
3

When you open the rasterize option, you have to edit (click on the pencil icon) the code, what you are looking for is the "burn" option of the gdal_rasterize parameter; you should erase the "-a WHATEVER_FIELD" argument, and replace it with "-burn 1" choose your "resolution" with either of these: "-ts" is raster size in pixels "-tr" is raster resolution in map units

gdal_rasterize -burn 1 -tr 1.0 1.0 -l your_layer D:/your_file.shp D:/your_file.tif

from gdal.org: "-burn value: A fixed value to burn into a band for all objects. A list of -burn options can be supplied, one per band being written to."

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.