Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to parse csv file and visualize it as geotiff using gdal_grid but I keep getting this error:

C:\work\testgdal1>gdal_grid -ot Float32 -l test  test.vrt dona.tif
ERROR 1: Failed to open datasource `test.csv'.
Unable to open input datasource "test.vrt".  
Failed to open datasource `test.csv'.

Both test.csv and test.vrt are in the same folder.

What can possibly go wrong and how to fix it?

Environment:

Windows 7 x64
osgeo4w as of 2 May 2011

test.vrt

<OGRVRTDataSource>
    <OGRVRTLayer name="test">
    <SrcDataSource>test.csv</SrcDataSource>        
    <SrcLayer>test</SrcLayer>
    <LayerSRS>WGS84</LayerSRS>
    <GeometryField encoding="PointFromColumns" x="field_10" y="field_9" z="field_20"/>
    <GeometryType>wkbPoint</GeometryType>
</OGRVRTLayer>

2 lines of test.csv

200010  207  020311    40658.5  406593 52 344927.31 7100203.50  -26.2078720  127.4491855 345060.64 7100369.14   26.4  650.3  628.0 55471.293    20.168 55648.817 55637.523  -146.062
200010  207  020311    40658.6  406594 52 344932.31 7100203.50  -26.2078726  127.4492355 345065.64 7100369.14   27.2  650.3  627.2 55456.719    20.172 55648.814 55637.520  -160.629
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Ah yes, I feel slightly to blame for this... I've just re-read the page on OGR's handling of CSV and it says that it only accepts commas, semi-colons, and tabs as field delimiters, but your file is fixed-width.

What you will need to do is convert each run of spaces to a comma. In Linux you can use a sed script, but as you're in Windows your options are a bit more limited. A simple way would be to load the ASCII file into a spreadsheet program, telling it to use fixed-width fields, then save it out telling it to use commas as separators. Not ideal, I grant you, but it is a technique I've used in the past.

share|improve this answer
    
ah thanks again, i suppose i can modify OGR code to support fixed-width :) –  portoalet May 2 '11 at 1:11
    
Ah yes, if you're of a programming bent, then your options are greater. If you do make a change to the OGR code, it'd be great if you could submit it as a patch on the gdal-dev mailing list. –  MerseyViking May 2 '11 at 8:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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