ASCIIrasters

Documentation for ASCIIrasters.

ASCIIrasters._check_nodataMethod
_check_nodata

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.

ASCIIrasters._read_dataMethod
_read_data

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

ASCIIrasters._read_headerMethod
_read_header

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

ASCIIrasters.read_asciiMethod
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.

Keywords

  • 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.

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

Writes data and header in an AAIGrid raster file.

Argument

  • dat: the AbstractArray of data to write

Keywords

Required:

  • 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

Optional:

  • 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.