lmpy.sdm.model

Module containing tools for creating an SDM.

Module Contents

Functions

_create_mask(point_tuples, ecoregions_filename, ...)

create_maxent_layer_label(sdm_dir, label_name[, ...])

Return a filename to indicate a layer label for an SDM raster in the directory.

create_sdm(min_points, csv_filename, env_dir, ...[, ...])

Create an SDM, Maxent model if there are enough points, rare species if not.

match_headers(mask_filename, tmp_mask_filename, ...)

Match headers with template layer.

project_sdm(maxent_lambdas_file, env_dir, ...[, logger])

Project a Maxent model onto env. layers for a potential distribution map.

Attributes

script_name

lmpy.sdm.model._create_mask(point_tuples, ecoregions_filename, env_dir, maxent_arguments, logger)[source]
lmpy.sdm.model.create_maxent_layer_label(sdm_dir, label_name, touch_file=True)[source]

Return a filename to indicate a layer label for an SDM raster in the directory.

Parameters
  • sdm_dir (str) – Path for output file, same as the dir for associated matrix input

  • label_name (str) – Name to use in matrix headers

  • touch_file (bool) – True to create the file

Returns

File signaling the

Return type

label_filename (str)

Note

This function assumes that only one SDM to be encoded will be in the same

directory.

lmpy.sdm.model.create_sdm(min_points, csv_filename, env_dir, ecoregions_filename, work_dir, species_name, maxent_arguments=DEFAULT_MAXENT_OPTIONS, sp_key=Point.SPECIES_ATTRIBUTE, x_key=Point.X_ATTRIBUTE, y_key=Point.Y_ATTRIBUTE, create_mask=True, logger=None)[source]

Create an SDM, Maxent model if there are enough points, rare species if not.

Parameters
  • min_points (int) – Number of points to determine whether to use Maxent or rare-species modeling

  • csv_filename (str) – input filename with species points

  • env_dir (str) – directory containing environmental layers for model creation

  • ecoregions_filename (str) – Vector file containing ecoregions or other environmental regions for masking in Maxent or intersecting with a convex hull in rare-species model

  • work_dir (str) – directory for temporary modeling files

  • maxent_arguments (str) – space-separated values for Maxent parameters

  • species_name (str) – name to use for the output model filename

  • sp_key (str) – fieldname of the column containing the species name for grouping

  • x_key (str) – fieldname of the column containing the longitude coordinate

  • y_key (str) – fieldname of the column containing the latitude coordinate

  • create_mask (bool) – flag indicating whether to create a mask for Maxent

  • logger (logging.logger) – Logger for writing messages to console and/or file.

Returns

either model raster filename for rare species model

or lambdas filename for Maxent

Return type

output_filename

report (dict): dictionary containing relevant metadata about the model

lmpy.sdm.model.match_headers(mask_filename, tmp_mask_filename, template_layer_filename)[source]

Match headers with template layer.

Parameters
  • mask_filename – Input filename to update with headers

  • tmp_mask_filename – Raster filename fromm which to copy the values above the 6th

  • template_layer_filename – Layer filename from which to copy the first 6 values

lmpy.sdm.model.project_sdm(maxent_lambdas_file, env_dir, species_name, work_dir, logger=None)[source]

Project a Maxent model onto env. layers for a potential distribution map.

Note

create_sdm creates a raster projected distribution map using the same environmental layers as were used for modeling. This function is intended to project an pre-created model onto different environmental layres.

Parameters
  • maxent_lambdas_file (str) – input filename with Maxent rules

  • env_dir (str) – directory containing environmental layers for model projection

  • work_dir (str) – directory for temporary modeling files

  • species_name (str) – name to use for the output model filename

  • logger (logging.logger) – Logger for writing messages to console and/or file.

Returns

output filename report (dict): dictionary containing relevant metadata about the model

Return type

projection_raster_filename

lmpy.sdm.model.script_name[source]