4

I'm using gdal_grid for the first time and get this issue:

gdal_grid -zfield field_3 -l layer0 OLEX-LAT-190952014.vrt OLEX-LAT-190952014.tiff
ERROR 1: Failed to find layer 'layer0' on datasource 'OLEX-LAT-190952014.short.csv'.
Failed to find field field_3 on layer layer0, skipping.

Here is what my vrt file looks like:

<OGRVRTDataSource>
<OGRVRTLayer name="layer0">
<SrcDataSource>OLEX-LAT-190952014.short.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>EPSG:25832</LayerSRS>
<GeometryField separator=" " encoding="PointFromColumns" x="field_1" y="field_2" z="field_3"/>
</OGRVRTLayer>
</OGRVRTDataSource>

And my data file:

field_1,field_2,field_3
6932193.2570,377160.7010,-33.1300
6932194.6430,377162.4380,-32.6600
  1. The first error mesage indicates that gdal_grid looks for a layer in the csv file - but how can a csv file contain a layer?
  2. The next error message indicates that gdal_grid has read the csv file and can't find field_3 although it is clearly there?

Any ideas what I'm doing wrong?

GDAL version 1.10.1

  • Try ogrinfo OLEX-LAT-190952014.vrt. Report will list the layer names which are found from the vrt (and csv). ogrinfo -al -so will list the attribute names. – user30184 Feb 2 '15 at 5:46
  • Thanks, ogrinfo didn't give any error messages. I figured it out, though - see below. – jollege Feb 2 '15 at 9:31
1

Use ogrinfo as a handy debugging tool. I see:

$ ogrinfo OLEX-LAT-190952014.vrt
INFO: Open of `OLEX-LAT-190952014.vrt'
      using driver `VRT' successful.
1: layer0ERROR 1: Failed to find layer 'layer0' on datasource 'OLEX-LAT-190952014.short.csv'. (Point)

According to the documentation, SrcLayer is optional, but should be defined (unless in SrcSQL). Add this after SrcDataSource:

<SrcLayer>OLEX-LAT-190952014.short</SrcLayer>

Alternatively, use OLEX-LAT-190952014.short for the layer name (line 2) in place of layer0.

  • 1
    Using the same name for .csv, .vrt and layer is always a good idea. – AndreJ Feb 2 '15 at 6:53
  • Thanks. What worked out in the end was to rename everyting to have exactly the same name - the layer, the csv file and the vrt file - all of them "OLEX-LAT-190952014_short". The <SrcLayer> had no effect. The output tiff is blank though? The suffix "short" is for testing using only 1000 points, the real data contains nearly 2 million points. I'm afraid that x and y fields have been swapped in the csv file. – jollege Feb 2 '15 at 8:59
  • Indeed, the first field in the csv file was Y/northing. I made it work by chaning the labels in the vrt file to '<GeometryField separator=" " encoding="PointFromColumns" x="easting" y="northing" z="z"/>' and the field names accordingly in the csv file. It looks correct now when I add it to my map! – jollege Feb 2 '15 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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