2

If I want to apply GDAL (version 2.2.3) on the LiDAR derived DTM (ASCII) from Slovenia (Link to Slovenian DTM below), I run into this error:

gdalinfo input.asc

ERROR 1: Ungridded dataset: At line 214, too many stepY values
gdalinfo failed - unable to open 'input.asc'.

The files can neither be loaded into QGIS (3.4.12).

I read here, that there is a XY swap in the files and sort can be used to get rid of the XY swap:

sort -k2 -n -k1 -t ';' input.asc -o output.xyz

However, after applying this to the .asc, I run into the following error:

gdalinfo output.xyz 

ERROR 1: Ungridded dataset: At line 1002, too many stepY values
gdalinfo failed - unable to open 'output.xyz'.

What can I do to apply GDAL to the data?

The LiDAR can be accessed for free here: ARSO. Here is a direct download link to a sample ASCII file (D48GK projection): GK1_444_106.asc

3

Your data is not a regular grid, you have missing points. The XYZ format description specifies "no missing value is supported".

Below is an image of a small section of the western edge of the data visualised as points showing the missing values.

enter image description here

To convert your data to raster, you can use gdal_grid. gdal_grid doesn't support the full range of OGR open options syntax (i.e see the CSV format description) so you need to create a VRT that tells gdal_grid how to create geometry from the X and Y fields.

<OGRVRTDataSource>
    <OGRVRTLayer name="GK1_444_106">
        <SrcDataSource>CSV:GK1_444_106.asc</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>EPSG:3794</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="field_1" y="field_2"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

You can then use gdal_grid to output a raster:

gdal_grid -a_srs EPSG:3912 -a nearest -txe 443999.5 445000.5 -tye 106999.65 105999.65 -outsize 1001 1000 -zfield field_3 -l GK1_444_106 GK1_444_106.vrt GK1_444_106.tif

enter image description here

  • Thank you. This helped. However, if I want to add the resulting Tiff's into a new virtual raster with gdalbuildvrt new.vrt GK1_444_106.tif, I get the following error: gdalbuildvrt does not support positive NS resolution. Skipping GK1_444_106.tif. What can I do? – youlion Oct 12 at 1:12
  • 1
    See edited gdal_grid command. I had upper & lower y coords in the wrong order. – user2856 Oct 12 at 4:32
  • Thanks! But if I use your given gdal_grid command, the process is unbelievable slow. It would take hours to produce one tif and I want to batch process this. However, if I use the command without the -txe and -tye option, the tif is produced fine in expected speed. But with this tif I run into the gdalbuildvrt does not support positive NS resolution. error. – youlion Oct 12 at 17:23
  • I also read on other sources, like here, that the EPSG for D48GK projection is EPSG:3912. – youlion Oct 12 at 17:41
  • 1
    I just used the CRS in your link. Using 3912 works fine for me (see edited command). Takes about 2sec per asc->tif conversion with gdal_grid (using -txt -tye so the resolution and extent are exactly as they should be) – user2856 Oct 12 at 21:25
1

Is it possible to use other software? I mean CloudCompare. It is free software that will generate geotiff quickly and easily in a few clicks. I made a simple gif with sample asc file:

CloudCompare

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.