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.
Asked
Active
Viewed 151 times
1
-
do you have QGIS or GDAL? – Michael Stimson 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. http://gis.stackexchange.com/questions/22704/how-to-convert-a-vector-layer-to-raster – Michael Stimson May 26 '14 at 23:49
-
also have a look at http://www.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. – Michael Stimson 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 00:06
-
No probs. GDAL has a C interface, from which I have used GDALRasterizeGeometries. It works quite well but is hard to find the documentation on. – Michael Stimson May 27 '14 at 00:27