I have a vector layer I need to rasterize. I guess this is a basic operation, but I haven't found the information I need yet.

First, I have reprojected the vector shapefile:

ogr2ogr -s_srs "+init=EPSG:3763" -t_srs "+proj=utm +zone=29 +north +west +datum=WGS84 +ellps=WGS84 +units=m +no_defs" CLC06_PT_WGS84.shp CLC06_PT.shp

The ogrinfo command on the new shapefile yields the following:

INFO: Open of CLC06_PT_WGS84.shp' using driverESRI Shapefile' successful.

Layer name: CLC06_PT_WGS84 Geometry: Polygon Feature Count: 46915 Extent: (248668.309849, 3768747.607570) - (537329.149160, 4365413.617030) Layer SRS WKT: PROJCS["WGS_1984_UTM_Zone_29N", GEOGCS["GCS_WGS_1984", DATUM["WGS_1984", SPHEROID["WGS_84",6378137,298.257223563]], PRIMEM["Greenwich",0], UNIT["Degree",0.017453292519943295]], PROJECTION["Transverse_Mercator"], PARAMETER["latitude_of_origin",0], PARAMETER["central_meridian",-9], PARAMETER["scale_factor",0.9996], PARAMETER["false_easting",500000], PARAMETER["false_northing",0], UNIT["Meter",1]] FID: Real (11.0)

now, I want to convert it to raster using gdal_rasterize. The original file contains information on land use (classed as attribute data), and I want that information to be rasterized.

I have tried the -3d option, but I was asked for the feature source, which is not the .dbf nor the .shx files created.

Another try was

gdal_rasterize -a FID -sql "select FID, * from CLC06_PT_WGS84" CLC06_PT_WGS84.shp CLC06_PT_WGS84.tif

but I got the error message

ERROR 4: `CLC06_PT_WGS84.tif' does not exist in the file system

I am using gdal 1.6

How can I achieve this? many thanks.

1 Answer 1


Have you tried to run the process in QGIS and to copy-paste the gdal_rasterize code at to bottom of the rasterize-tool? Just to see if code and error message are the same ...

  • thanks for your answer and help. I haven't, but I would prefer to keep the whole thing under CLI and GDAL for automation purposes. Jul 31, 2014 at 14:38
  • i guess, when you copy-paste the code from QGIS you should still be able to automate the process as you wish; it would (maybe) just be an option to check code and syntax as it is the same gdal-tool
    – Flo
    Jul 31, 2014 at 14:58
  • I am not at all at ease with QGIS. Doing some fiddling, I managed to arrive to a raster: setting the -tr or -ts option with gdal_rasterize. In my case, since I want information every 50 metres, I set -tr 50 50. Aug 5, 2014 at 15:02
  • well, it seems I do not get what I want (3 numbers classifiers) in the ASCII file. I guess that has to do with the -a FID -sql "select FID, * from CLC06_PT_WGS84" options for the gdal_rasterize command. Any help How I can understand which field to burn on the raster? Aug 5, 2014 at 19:38
  • 2
    SOLVED. The ogrinfo with the right flags (-al -so) yielded information on the fields, so that I was able to identify the 'CODE_06' field as the one containing the information on land use. The command to produce the tiff is then gdal_rasterize -tr 50 50 -a CODE_06 -l CLC06_PT_WGS84 CLC06_PT_WGS84.shp CLC06_PT_WGS84.tiff Aug 12, 2014 at 9:58

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.