1

I am using gdal_grid module(from gdal 1.10) and it has some problem with reading the vrt file. I checked this link but it does not work. gdal_grid problem reading vrt file

The command is

./gdal_grid -l grid grid.vrt newgrid.tif

The Error Message is

Unable to open input datasource "grid.vrt".

The vrt file is like following

<ORGVRTDataSource>
    <OGRVRTLayer name="grid">
        <SrcDataSource>grid.csv</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>WGS84</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="x" y="y" z="z"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

The csv file is like following

x,y,z
565650,5121960,1048
565680,5121960,1043
565710,5121960,1039
565740,5121960,1038
565770,5121960,1036
565800,5121960,1024

Thanks.

4

I'm afraid it is a typo in the first line. Try:

<OGRVRTDataSource>
    <OGRVRTLayer name="grid">
        <SrcDataSource>grid.csv</SrcDataSource>
        <GeometryType>wkbPoint25D</GeometryType>
        <LayerSRS>WGS84</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="x" y="y" z="z"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

I also changed the GeometryType to wkbPoint25D so it includes the Z values in the geometry

You can test with 'ogrinfo -so -al grid.vrt' to see that it isn't a problem specific to gdal_grid and to see how the driver translates your files:

$ ogrinfo -al grid.vrt 

INFO: Open of `grid.vrt'
      using driver `VRT' successful.

Layer name: grid
Geometry: 3D Point
Feature Count: 6
Extent: (565650.000000, 5121960.000000) - (565800.000000, 5121960.000000)
Layer SRS WKT:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        TOWGS84[0,0,0,0,0,0,0],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9108"]],
    AUTHORITY["EPSG","4326"]]
x: String (0.0)
y: String (0.0)
z: String (0.0)
OGRFeature(grid):1
  x (String) = 565650
  y (String) = 5121960
  z (String) = 1048
  POINT (565650 5121960 1048)

OGRFeature(grid):2
  x (String) = 565680
  y (String) = 5121960
  z (String) = 1043
  POINT (565680 5121960 1043)

Note that the fields associated with each feature are strings. You could change them to be other types with a grid.csvt file:

"Real","Real","Real"

gives ... x: Real (0.0) y: Real (0.0) z: Real (0.0) OGRFeature(grid):1 x (Real) = 565650 y (Real) = 5121960 z (Real) = 1048 POINT (565650 5121960 1048)

OGRFeature(grid):2
  x (Real) = 565680
  y (Real) = 5121960
  z (Real) = 1043
  POINT (565680 5121960 1043)
...

It happily pretends the large numbers are geographic, so a mis-specified SRS doesn't cause a error at this stage.

"UTM" as a LayerSRS causes problems since it doesn't choose a specific UTM zone. You might need something like 'EPSG:32618' or '+proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'

1

I can see to possible sources of error in your vrt :

  1. You use relative path, so the vrt may not find the .csv file if not in the same directory
  2. You state a layer SRS in WGS84 (= lat long) but the coordinates in your csv are definitely not geographic coordinates. This look more like a global projected coordinate system or some UTM (but this is just a guess, many other projected coordiante system could have those coordinates, however I do not expect more "local" projections to have such large Y values like here)
  • Hi radouxju. Thanks for your help. 1. I am sure all the files are in the same directory. 2. Yes, you are right. It's in UTM format. But after I changed the value to "UTM", same error appeared. I don't know why :( – user26414 Feb 1 '14 at 9:10

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.