I am still bit new to Postgis 2.1. I am trying to rasterize a polygon, meaning that I have a polygon of Syria and I want to create an empty raster that contains the shape and geography reference of syria. I have been looking at the ST_AsRaster() function, but I can't seem to figure out the settings for this. Any suggestions.

  • do you have QGIS or GDAL? May 26 '14 at 23:43
  • So I can do this in QGIS, but it seems rather inefficient to save the geography polygon in Postgis, then pull it into QGIS for processing, and then save the result back into Postgis for subsequent raster band work with st_intersection(). Isn't there an easier way?
    – krishnab
    May 26 '14 at 23:47
  • QGIS can read PostGis geometry types. Have a look at this post and see if it suits your needs. gis.stackexchange.com/questions/22704/… May 26 '14 at 23:49
  • also have a look at gdal.org/gdal_rasterize.html. use -tr X Y to set the out cell size and -of to set the output type. I think it will reference PostGis directly being an OGR supported format but have no experience doing such. May 26 '14 at 23:57
  • Thanks @MichaelMiles-Stimson , Yeah, I was able to get this running through QGIS 2.2. It actually gives me the full gdal_rasterize syntax. Hmm, I might have to write a postgresql/postgis c-extension to help me do this through the database. Thanks for your help.
    – krishnab
    May 27 '14 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.