I'm looking to do something which seem simple to me, but I haven't found a solution since 2 days I looked for.

I've got a Postgis DB with lot of points (WGS84) spaced of 100 meters which cover a territory. For each of these points, I've got a value associated. I want to convert all theses point to a raster Geotiff.

The ideal process will make a Geotiff file where each pixels corresponds to the value of the corresponding points of the db.

I tried the heatmap plug-in of QGIS, but It doesn't do what I want, it interpolate lot of new points I don't need, I want in the tiff file only values I've got in my database.

Any suggestion about how to easily generate this file ?

2 Answers 2


A couple of options:

  1. Convert the PostGIS layer to a shapefile in QGIS (save-as), then use the Vector|Conversion|Rasterize tool;
  2. Use the gdal_rasterize command directly.

For the second option:

gdal_rasterize -a VAL -ts [x] [y] PG:'host=localhost dbname=DB user=USER'  
  -sql "SELECT the_geom, VAL FROM table" out.tif


  • VAL = the value to assign to the raster (same as the VAL in the SELECT statement);
  • [x] [y] are the X and Y dimensions of the extent of the point table;
  • DB and USER are the database and username;
  • the_geom and VAL are the geometry and value columns you're interested in from 'table', respectively;
  • out.tif is the output TIF file.

Note: the heatmap plugin doesn't interpolate values - it uses something like a kernel density algorithm to smooth known values for areas around the measured points.

  • It works ! Thanks a lot. I think, the possibility of Postgis connexion is not written in the gdal_rasterize manual gdal.org/gdal_rasterize.html . Now, I have to find a way a complete pixel where I have got no value.
    – Jérôme B
    Apr 10, 2014 at 17:13
  • I've got some mistake with the -tr option of gdal_rasterize, if you got time to help me, I would be very nice, If not never mind : gis.stackexchange.com/questions/92797/…
    – Jérôme B
    Apr 11, 2014 at 14:10
  • Simbamangu, can I use gdal_rasterize to turn a csv of lat/long (or point shapefile) into a raster, where each cell represents the number of points that are within that cell? Thank you
    – user20408
    Dec 11, 2014 at 18:44

You could try the Rasterize tool in QGIS (Raster - Conversion)

  • Thanks for your answer, the tool works only from shp file. I'll look if QGis can generate this ckind of file.
    – Jérôme B
    Apr 10, 2014 at 16:00
  • 1
    Yes QGIS can make a shapefile. You can load your PostGIS point table into QGIS and save it as a shapefile (right click on the PostGIS layer and choose Save As). Apr 10, 2014 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.