2

I would like to convert a vrt file into a raster dataset using gdal_translate. I am doing the following:

gdal_translate in.vrt out.tif

However I get the following error:

`ERROR 4: 'in_vrt' not recognized as a supported file format.

I have checked and rechecked my file name and path and I can't figure out what I'm doing wrong. I tried opening in Arcmap and got this error message:

Invalid raster dataset. Failed to create raster layer

and in QGIS I got:

Invalid Layer: GDAL provider Cannot open GDAL dataset in.vrt: `in.vrt' not recognized as a supported file format. Raster layer Provider is not valid (provider: gdal, URI: in.vrt

Does anyone know what I am doing wrong? How can I open this vrt file with no errors?

EDIT Here are a few lines from a typical vrt I am using

<OGRVRTDataSource>
        <OGRVRTLayer name="gouda_rws_env_dsc_v3_ds_qh">
            <SrcDataSource>gouda_rws_env_dsc_v3_ds_qh.csv</SrcDataSource>
            <GeometryType>wkbPoint</GeometryType>
            <LayerSRS>WGS84</LayerSRS>
            <GeometryField encoding="PointFromColumns" x="pnt_lon" y="pnt_lat"/>
            <Field name="pnt_id" src="pnt_id" type="String" />
            <Field name="pnt_lat" src="pnt_lat" type="Real" />
            <Field name="pnt_lon" src="pnt_lon" type="Real" />
            <Field name="pnt_rdx" src="pnt_rdx" type="Real" />
            <Field name="pnt_rdy" src="pnt_rdy" type="Real" />
            <Field name="pnt_demheight" src="pnt_demheight" type="Real" />
            <Field name="pnt_height" src="pnt_height" type="Real" />
5
  • check for mispells. is it in_vrt or in.vrt? Open the file into a text editor. Does it look like an xml file?
    – nickves
    Nov 9, 2018 at 15:56
  • No I am not mispelling it. It is indeed an xml file but I do notice there are multiple fields. Do I somehow have to define these in the gdal_translate command?
    – user32882
    Nov 9, 2018 at 16:00
  • IIRC, in some instances QGIS wants the filetype in the name of the VRT file. e.g. a VRT of GeoTIFFs named Some raster map.vrt might fail while the same VRT file named Some raster map.tif.vrt would work. I could be well be mis-remembering though. Nov 9, 2018 at 21:35
  • But my file is called "in.vrt" according to the file explorer
    – user32882
    Nov 10, 2018 at 4:55
  • If the file you showed a sample of is one of the ones that's failing then try renaming the VRT file from "in.vrt" to "in.csv.vrt" Nov 10, 2018 at 21:57

1 Answer 1

1

Your VRT is a vector dataset. gdal_translate is used to convert between raster formats not from vector to raster.

Instead, you can use:

  • ogr2ogr to output a shapefile or other vector format,
    • QGIS Processing toolbox | GDAL | Vector Conversion | Convert format
  • gdal_rasterize to burn the points to a tiff, or
    • QGIS Processing toolbox | GDAL | Vector Conversion | Rasterize
  • gdal_grid to interpolate the points to a surface raster (I noticed some elevation fields in your VRT).
    • QGIS Processing toolbox | GDAL | Raster Analysis | Grid (*)

If the underlying CSV file is meant to be a raster dataset in XYZ format, gdal/QGIS should be able to read it directly as a raster if you drop the additional fields and just keep the "pnt_lon", "pnt_lat" and "pnt_height" (OR "pnt_demheight" but not both), sorted by lat then by lon. You could then use gdal_translate xyz.csv out.tif

GDAL supports reading and writing ASCII gridded XYZ raster datasets (i.e. ungridded XYZ, LIDAR XYZ etc. must be opened by other means. See the documentation of the gdal_grid utility).

Those datasets are ASCII files with (at least) 3 columns, each line containing the X and Y coordinates of the center of the cell and the value of the cell.

The spacing between each cell must be constant and no missing value is supported. Cells with same Y coordinates must be placed on consecutive lines. For a same Y coordinate value, the lines in the dataset must be organized by increasing X values. The value of the Y coordinate can increase or decrease however. The supported column separators are space, comma, semicolon and tabulations.

The driver tries to autodetect an header line and will look for 'x', 'lon' or 'east' names to detect the index of the X column, 'y', 'lat' or 'north' for the Y column and 'z', 'alt' or 'height' for the Z column. If no header is present or one of the column could not be identified in the header, the X, Y and Z columns (in that order) are assumed to be the first 3 columns of each line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.