Package: elapid
elapidContemporary species distribution modeling tools for python.Documentation:earth-chris.github.io/elapidSource code:earth-chris/elapid:snake: Introductionelapidis a series of species distribution modeling tools for python. This includes a custom implementation ofMaxentand a suite of methods to simplify working with biogeography data.The name is an homage toA Biogeographic Analysis of Australian Elapid Snakes(H.A. Nix, 1986), the paper widely credited with defining the essential bioclimatic variables to use in species distribution modeling. It's also a snake pun (a python wrapper for mapping snake biogeography).:seedling: Installationpip install elapidorconda install -c conda-forge elapidInstallingglmnetis optional, but recommended. This can be done withpip install elapid[glmnet]orconda install -c conda-forge elapid glmnet. For more support, and for information on why this package is recommended, seethis page.Thecondainstall is recommended for Windows users. While there is apipdistribution, you may experience some challenges. The easiest way to overcome them is to useWindows Subsystem for Linux (WSL). Otherwise, seethis pagefor support.:deciduous_tree: Why use elapid?The amount and quality of bioegeographic data has increased dramatically over the past decade, as have cloud-based tools for working with it.elapidwas designed to provide a set of modern, python-based tools for working with species occurrence records and environmental covariates to map different dimensions of a species' niche.elapidsupports working with modern geospatial data formats and uses contemporary approaches to training statistical models. It usessklearnconventions to fit and apply models,rasterioto handle raster operations,geopandasfor vector operations, and processes data under the hood withnumpy.This makes it easier to do things like fit/apply models to multi-temporal and multi-scale data, fit geographically-weighted models, create ensembles, precisely define background point distributions, and summarize model predictions.It does the following things reasonably well::globe_with_meridians:Point samplingSelect random geographic point samples (aka background or pseudoabsence points) within polygons or rasters, handlingnodatalocations, as well as sampling from bias maps (usingelapid.sample_raster(),elapid.sample_vector(), orelapid.sample_bias_file()).:chart_with_upwards_trend:Vector annotationExtract and annotate point data from rasters, creatingGeoDataFrameswith sample locations and their matching covariate values (usingelapid.annotate()). On-the-fly reprojection, dropping nodata, multi-band inputs and multi-file inputs are all supported.:bar_chart:Zonal statisticsCalculate zonal statistics from multi-band, multi-raster data into a singleGeoDataFramefrom one command (usingelapid.zonal_stats()).:bug:Feature transformationsTransform covariate data into derivativefeaturesto expand data dimensionality and improve prediction accuracy (likeelapid.ProductTransformer(),elapid.HingeTransformer(), or the all-in-oneelapid.MaxentFeatureTransformer()).:bird:Species distribution modelingTrain and apply species distribution models based on annotated point data, configured with sensible defaults (likeelapid.MaxentModel()andelapid.NicheEnvelopeModel()).:satellite:Training spatially-aware modelsCompute spatially-explicit sample weights, checkerboard train/test splits, or geographically-clustered cross-validation splits to reduce spatial autocorellation effects (withelapid.distance_weights(),elapid.checkerboard_split()andelapid.GeographicKFold()).:earth_asia:Applying models to rastersApply any pixel-based model with a.predict()method to raster data to easily create prediction probability maps (like training aRandomForestClassifier()and applying withelapid.apply_model_to_rasters()).:cloud:Cloud-native geo supportWork with cloud- or web-hosted raster/vector data (onhttps://,gs://,s3://, etc.) to keep your disk free of temporary files.Check out some example code snippets and workflows on theWorking with Geospatial Datapage.:snake:elapidrequires some effort on the user's part to draw samples and extract covariate data. This is by design.Selecting background samples, computing sample weights, splitting train/test data, and specifying training parameters are all critical modeling choices that have profound effects on inference and interpretation.The extra flexibility provided byelapidenables more control over the seemingly black-box approach of Maxent, enabling users to better tune and evaluate their models.Developed byChristopher Anderson[^1] [^2][^1]:EO Lab, Planet Labs PBC[^2]:Center for Conservation Biology, Stanford University