read_mxe: Read raster data stored in Maxent's mxe format

View source: R/read_mxe.R

read_mxeR Documentation

Read raster data stored in Maxent's mxe format

Description

Read (and optionally clip) binary mxe files created by the Maxent habitat suitability modelling software package.

Usage

read_mxe(file, ext, snap = "near", chunk_size = 1e+05, return_raster = TRUE)

Arguments

file

The path to the mxe file to be read.

ext

(Optional) An extent to clip the grid to. This must be either an Extent object, a ⁠SpatialPolygons*⁠, or a numeric vector with four elements in the order xmin xmax, ymin, ymax.

snap

Character. One of 'near', 'out', or 'in'. This will adjust the extent given in ext such that it aligns with the raster data being read. Note that currently, supplying 'out' or 'in' will result in the extent being expanded/contracted even if the provided extent already aligns with the grid. snap is ignored if ext is not provided.

chunk_size

A numeric value specifying the size of the chunk of binary data to be read at a time (size is usually in units of KB of data). chunk_size is ignored if ext is not provided. If clipping the imported data (i.e. if ext is provided), the raster data are read in chunks, with chunk_size values being read, and subsequently filtered to those values within the desired extent, at a time. Decreasing chunk_size leads to lower system memory demand, but also to longer processing time.

return_raster

Logical. If FALSE, then the cell values data will returned as a vector; if TRUE, a raster object will be returned.

Value

If return_raster is TRUE, a raster object. If return_raster is FALSE, a list is returned, with the following elements:

  • xll: The x coordinate of the lower left corner of the extent.

  • yll: The y coordinate of the lower left corner of the extent.

  • res: The grid resolution. Note that horizontal and vertical resolution are assumed equal.

  • nrow: The number of rows of data.

  • ncol: The number of columns of data.

  • nodata: The nodata value.

  • datatype: A character string indicating the data type.

  • data: A vector whose elements are the raster cell values.

References

Based on "Reading mxe files with R - revisited" by Peter D. Wilson.

See Also

project()


johnbaums/rmaxent documentation built on Oct. 11, 2024, 11:14 a.m.