ee.Classifier.amnhMaxent

Creates a Maximum Entropy classifier. Maxent is used to model species distribution probabilities using environmental data for locations of known presence and for a large number of 'background' locations. For more information and to cite, see: https://biodiversityinformatics.amnh.org/open_source/maxent/ and the reference publication: Phillips, et. al., 2004 A maximum entropy approach to species distribution modeling, Proceedings of the Twenty-First International Conference on Machine Learning. The output is a single band named 'probability', containing the modeled probability, and an additional band named 'clamp' when the 'writeClampGrid' argument is true.

UsageReturns
ee.Classifier.amnhMaxent(categoricalNames, outputFormat, autoFeature, linear, quadratic, product, threshold, hinge, hingeThreshold, l2lqThreshold, lq2lqptThreshold, addSamplesToBackground, addAllSamplesToBackground, betaMultiplier, betaHinge, betaLqp, betaCategorical, betaThreshold, extrapolate, doClamp, writeClampGrid, randomTestPoints, seed)Classifier
ArgumentTypeDetails
categoricalNamesList, default: nullA list of the names of the categorical inputs. Any inputs not listed in this argument are considered to be continuous.
outputFormatString, default: "cloglog"Representation of probabilities in output.
autoFeatureBoolean, default: trueAutomatically select which feature classes to use, based on number of training samples.
linearBoolean, default: trueAllow linear features to be used. Ignored when autofeature is true.
quadraticBoolean, default: trueAllow quadratic features to be used. Ignored when autofeature is true.
productBoolean, default: trueAllow product features to be used. Ignored when autofeature is true.
thresholdBoolean, default: falseAllow threshold features to be used. Ignored when autofeature is true.
hingeBoolean, default: trueAllow hinge features to be used. Ignored when autofeature is true.
hingeThresholdInteger, default: 15Number of samples at which hinge features start being used. Ignored when autofeature is false.
l2lqThresholdInteger, default: 10Number of samples at which quadratic features start being used. Ignored when autofeature is false.
lq2lqptThresholdInteger, default: 80Number of samples at which product and threshold features start being used. Ignored when autofeature is false.
addSamplesToBackgroundBoolean, default: trueAdd to the background any sample for which has a combination of environmental values that isn't already present in the background.
addAllSamplesToBackgroundBoolean, default: falseAdd all samples to the background, even if they have combinations of environmental values that are already present in the background.
betaMultiplierFloat, default: 1Regularization multiplier. Multiply all automatic regularization parameters by this number. A higher number gives a more spread-out distribution.
betaHingeFloat, default: -1Regularization parameter to be applied to all hinge features; negative value enables automatic setting.
betaLqpFloat, default: -1Regularization parameter to be applied to all linear, quadratic and product features; negative value enables automatic setting.
betaCategoricalFloat, default: -1Regularization parameter to be applied to all categorical features; negative value enables automatic setting.
betaThresholdFloat, default: -1Regularization parameter to be applied to all threshold features; negative value enables automatic setting.
extrapolateBoolean, default: trueExtrapolate. Predict to regions of environmental space outside the limits encountered during training.
doClampBoolean, default: trueApply clamping to output.
writeClampGridBoolean, default: trueAdds a band to the output ('clamp') showing the spatial distribution of clamping. At each point, the value is the absolute difference between prediction values with and without clamping.
randomTestPointsInteger, default: 0Random test percentage. The percentage of training points to hold aside as test points, used to compute AUX, omission, etc.
seedLong, default: 0A seed used when generating random numbers.

Examples

Code Editor (JavaScript)

// Create some sample species presence/absence training data.
var trainingData = ee.FeatureCollection([
  // Species present points.
  ee.Feature(ee.Geometry.Point([-122.39567, 38.02740]), {presence: 1}),
  ee.Feature(ee.Geometry.Point([-122.68560, 37.83690]), {presence: 1}),
  // Species absent points.
  ee.Feature(ee.Geometry.Point([-122.59755, 37.92402]), {presence: 0}),
  ee.Feature(ee.Geometry.Point([-122.47137, 37.99291]), {presence: 0}),
  ee.Feature(ee.Geometry.Point([-122.52905, 37.85642]), {presence: 0}),
  ee.Feature(ee.Geometry.Point([-122.03010, 37.66660]), {presence: 0})
]);

// Import a Landsat 8 surface reflectance image.
var image = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20200606')
                // Select the optical and thermal bands.
                .select(['.._B.*']);

// Sample the image at the location of the points.
var training = image.sampleRegions({collection: trainingData, scale: 30});

// Define and train a Maxent classifier from the image-sampled points.
var classifier = ee.Classifier.amnhMaxent().train({
  features: training,
  classProperty: 'presence',
  inputProperties: image.bandNames()
});

// Classify the image using the Maxent classifier.
var imageClassified = image.classify(classifier);

// Display the layers on the map.
// Species presence probability [0, 1] grades from black to white.
Map.centerObject(image, 9);
Map.addLayer(
    image.select(['SR_B4', 'SR_B3', 'SR_B2']).multiply(0.0000275).add(-0.2),
    {min: 0, max: 0.3}, 'Image');
Map.addLayer(
    imageClassified, {bands: 'probability', min: 0, max: 1}, 'Probability');
Map.addLayer(
    trainingData.filter('presence == 0'), {color: 'red'},
    'Training data (species absent)');
Map.addLayer(
    trainingData.filter('presence == 1'), {color: 'blue'},
    'Training data (species present)');

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

import ee
import geemap.core as geemap

Colab (Python)

"""Demonstrates the ee.Classifier.amnhMaxent method."""

import ee


# Authenticates to the Earth Engine servers.
ee.Authenticate()
# Initializes the client library.
ee.Initialize()


# Create some sample species presence/absence training data.
training_data = ee.FeatureCollection([
    # Species present points.
    ee.Feature(ee.Geometry.Point([-122.39567, 38.02740]), {'presence': 1}),
    ee.Feature(ee.Geometry.Point([-122.68560, 37.83690]), {'presence': 1}),
    # Species absent points.
    ee.Feature(ee.Geometry.Point([-122.59755, 37.92402]), {'presence': 0}),
    ee.Feature(ee.Geometry.Point([-122.47137, 37.99291]), {'presence': 0}),
    ee.Feature(ee.Geometry.Point([-122.52905, 37.85642]), {'presence': 0}),
    ee.Feature(ee.Geometry.Point([-122.03010, 37.66660]), {'presence': 0})
])

# Import a Landsat 8 image and select the reflectance bands.
image = (ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20200606')
         .select(['SR_B[1-7]'])
         .multiply(0.0000275).add(-0.2))  # Apply scaling factors.

# Sample the image at the location of the points.
training = image.sampleRegions(**{
    'collection': training_data,
    'scale': 30
})

# Define and train a Maxent classifier from the image-sampled points.
classifier = ee.Classifier.amnhMaxent().train(**{
    'features': training,
    'classProperty': 'presence',
    'inputProperties': image.bandNames()
})

# Classify the image using the Maxent classifier.
image_classified = image.classify(classifier)