[gdal-dev] Opening gridded xyz data that is out of order

Andreas Neumann a.neumann at carto.net
Mon Sep 11 07:32:42 PDT 2017


Hi Mark (and others),

Your sort command worked like a charm. It was also very fast!

Now gdalinfo produces this nice information output:

Driver: XYZ/ASCII Gridded XYZ
Files: dtmav_sorted.xyz
Size is 5000, 5000
Coordinate System is `'
Origin = (2708000.000000000000000,1210000.000000000000000)
Pixel Size = (2.000000000000000,2.000000000000000)
Corner Coordinates:
Upper Left  ( 2708000.000, 1210000.000)
Lower Left  ( 2708000.000, 1220000.000)
Upper Right ( 2718000.000, 1210000.000)
Lower Right ( 2718000.000, 1220000.000)
Center      ( 2713000.000, 1215000.000)
Band 1 Block=5000x1 Type=Float32, ColorInterp=Undefined
   Min=728.210 Max=2294.290
   NoData Value=0

Now I can open this in QGIS as a normal data source and simply safe as a 
GeoTIFF file.

Thanks a lot to all who answered so quickly!

Glad that a simple sort command on the command line helped to solve the 
issue! I will contact the data provider and ask them if they could 
deliver this data in an already sorted form so that GDAL recognizes it 
as gridded data.

Andreas


On 11.09.2017 16:12, Mark Johnson wrote:
> You must sort the data beforehand
> - the y position must be sorted properly (ASC or DESC)
>
> Standard linux sort program:
>
> sort -k2 -n -k1 392_5810.xyz <http://392_5810.xyz> -o 
> 392_5810.sort.xyz <http://392_5810.sort.xyz>
>
> (2nd column (y) as numeric, then first column (x) -o = output file
>
> As a zip file you can also do:
>
> unzip -p 390_5820.zip | sort -k2 -n -k1 -o ../xyz/390_5820.dhhn92.txt
>
> that would deal with problem in 1 step.
>
> ogr needs to know the range/area to build (minx,miny,maxx, maxy), so 
> when the y switches it assumes a new column.
>
> Mark
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170911/104f7d51/attachment-0001.html>


More information about the gdal-dev mailing list