[gdal-dev] ASCII Gridded XYZ and "Hectare Raster" data (STATPOP and STATENT)
Even Rouault
even.rouault at spatialys.com
Sun Apr 21 02:31:30 PDT 2019
Stefan,
>
> The Swiss Statistical Office curates well-known datasets informally
> called "Hectare Raster" (STATPOP and STATENT) which obviously are
> ASCII Gridded XYZ, like this:
>
> "RELI" "X" "Y" "C1" "C2" "C3"
> 66192542 661900 254200 1 2 3 ...
> 66192543 661900 254300 1 2 3 ...
> 66192599 661900 259900 1 2 3 ...
> 66192600 661900 260000 1 2 3 ...
> ...
>
> This obviously is a regular gridded X and Y, sorted by X,Y but
> obviously also has gaps and more than one "Z" (C1, C2, C3). Typically
> this is converted to a raster format like GeoTIFF and analysed through
> map algebra.
>
> Question 1: The GDAL docs (https://www.gdal.org/frmt_xyz.html ) says
> "...no missing value is supported.". In fact, I think it supports them
> by omitting lines by setting missing "lines" to NODATA.
> => Correct?
The driver is quite picky. I don't think it will support missing values in the
middle of a line of same Y value. It supports missing values at the beginning
or end of a line of same Y value. And points must be sorted by increasing or
decreasing Y, and increasing X value for a line of same Y value.
>
> Question 2: I think, there is a way (which could be mentioned in the
> docs above), to determine the "Z" value to be converted by gdal_grid
> explained in "Reading comma separated values"
> (https://www.gdal.org/gdal_grid.html#gdal_grid_csv ).
> So XYZ in fact is XYZx meaning that potentially there can be many "Z"
> in the input file, but only one can be included.
> => What do you think?
The best way might probably to read the file with the CSV driver indeed. With
CSV:the_filename if the_filename has not a .csv extension
Convert it to something with a spatial index like a shapefile or GPKG if the
file is big
And then use gdal_grid to create a raster from it.
>
> Question 3 (the fundamental one): Although XYZ format requires to
> contain regular gridded coordinates, it's technically handled the same
> as irregular coordinates (without interpolation) - at least regarding
> the main task to convert an sparse array of values to a raster format.
> => Correct?
The XYZ driver requires constant spacing.
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list