Documentation for ASCIIrasters.


If nodatavalue is a header line, keep it as nodatavalue and detect its type. If nodatavalue is missing, we set it to -9999.0 and its type to Any.


Looks in header for a number of lines to ignore, then writes the following lines in a matrix with required element type.


Reads the first lines that don't start with a number. Converts them to a Dict with 9 entries with all the parameters we need both for assessing data type and keeping header parameters.

read_ascii(filename::AbstractString) => Union{Tuple{Array, NamedTuple}, NamedTuple}

Reads an ASCII file. Parameters are parsed according to the AAIGrid format. Data elements are assumed to be of the same type as the nodatavalue header parameter if possible. If there is no nodata_value field in the header, data type is estimated by checking if there are any floating numbers in the first 10 data rows.


  • lazy: when set to true, only the header of filename will be read, and only the NamedTuple of parameters be returned.

If not lazy, returns a Tuple with: an Array of the data and a NamedTuple of the header information.

write_ascii(filename::AbstractString; kwargs...)

Writes data and header in an AAIGrid raster file.


  • dat: the AbstractArray of data to write



  • ncols and nrows: numbers of columns and rows
  • xll and yll: coordinates of the lower-left corner
  • dx and dy: dx and dy cell sizes in coordinate units per pixel


  • nodatavalue: a value that should be considered as representing no data. Default is -9999.0
  • detecttype: when set to true, elements of dat are converted to the same type as nodatavalue. Leave false to coerce everything (both dat and nodatavalue) to Float32.

Returns the written file name.