1

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

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
2
  • 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 mille Commented 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. Commented Nov 30, 2013 at 10:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.