I would like to use a string as src_datasource for gdal_rasterize program.
Is it possible to use something like a WKT definition to translate a single point to a raster?
Something like:
gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 0 -burn 0 -l mask "POINT(6 10)" work.tif
nmtoken
13.6k5 gold badges39 silver badges91 bronze badges
asked Nov 29, 2013 at 18:04
1 Answer 1
Yes, you need to write a CSV file, e.g. point.csv
:
id,WKTgeom
1,POINT(6 10)
and then an OGR VRT file, e.g. point.vrt
:
<OGRVRTDataSource>
<OGRVRTLayer name="point">
<SrcDataSource relativeToVRT="0">point.csv</SrcDataSource>
<SrcLayer>point</SrcLayer>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
<GeometryField encoding="WKT" field="WKTgeom"/>
</OGRVRTLayer>
</OGRVRTDataSource>
Finally, you can execute something like:
gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 0 -burn 0 -l point point.vrt work.tif
Note:
work.tif
must exist before you run gdal_rasterize
and have three bands.
answered Nov 29, 2013 at 19:17
-
Ciao Antonio, I know I can use a CSV via a .vrt file, but I have another goal. I'm looking for a way to convert a single a pair of coordinates to a raster file, without the need to create other external files. Probably it's not possible. I think it's possible in GRASS. Grazie milleaborruso– aborruso2013年11月30日 10:06:58 +00:00Commented Nov 30, 2013 at 10:06
-
I think that it's not possible, because you should specify other properties of the raster file (SRS, GeoTransform, etc.). GDAL Virtual Format is the right way in this case.Antonio Falciano– Antonio Falciano2013年11月30日 10:16:03 +00:00Commented Nov 30, 2013 at 10:16
default