I'm trying to convert a multipolygon vector layer to a raster using the GDAL tool gdal_rasterize
. The command I am using is:
gdal_rasterize -b 1 -burn -9999 PG:"dbname=db password=password" \
auckland auckland.png
However, it seems my specification of the source for the postgis layer is incorrect as I get an
ERROR 4: 'auckland.png' does not exist in the file system,
and is not recognised as a supported dataset name.`
So how do I successfully connect to postgres and export a vector as a tif? Is it possible?
Numerous other attempts have included:
gdal_rasterize -b 1 -i -burn -9999 PG:"dbname=db password=" -l \
auckland auckland.png
gdal_rasterize -b 1 -i -burn -9999 -l auckland PG:"dbname=db \
password=password" auckland.png
And this one from Roger's Rants:
gdal_rasterize -b 1 -i -burn -9999 PG:'host=localhost dbname='unep'' \
-sql "SELECT ST_buffer(the_geom, .12) from coastlines where name='Poland'" \
Poland_elev.tif
When I use ogr2ogr
to export the layer out of postgres as a shapefile, and then gdal_rasterize
to convert to a .tif
file it all works smoothly.
Using GDAL 1.11.2 version on Ubuntu 15.10.
Still no love with either:
gdal_rasterize -b 1 -burn -9999 PG:"dbname=db password=pwd" \
-l auckland auckland.tif
or:
gdal_rasterize -b 1 -burn -9999 -l auckland PG:"dbname=db \
password=pwd" auckland.tif
Answer
To create a new raster with gdal_rasterize, either the -tr
or -ts
option must be used, and the -b
option cannot be used.
E.g.
gdal_rasterize -burn -9999 -tr 0.001 0.001 PG:"..." -l auckland auckland.tif
No comments:
Post a Comment