Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 ?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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

Where:

  • 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.

share|improve this answer
    
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 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 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 at 18:44

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

share|improve this answer
    
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 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). –  Ryan Garnett Apr 10 at 16:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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