# Species Distribution Modeling in R

See how species distribution modeling in R works, from occurrence data cleaning and environmental raster layers to fitting models in dismo, biomod2 and sdm.

Species distribution modeling in R links field records to environmental raster layers to map suitable habitat. The R statistical environment offers free packages that handle each step, from cleaning sightings to drawing prediction maps. For prairie birds, the same workflow can suggest where a species may breed, winter or stop during migration. 

## Cleaning occurrence data before modeling 

Occurrence data cleaning is the first step of species distribution modeling, because errors in records pass into maps. Typical problems include duplicate sightings, swapped coordinates, and points placed at a country center or a museum. Spatial thinning, which keeps one record per grid cell, reduces clusters of sightings near roads and towns. Bird checklist records also need a date check, so migrants are not mistaken for breeding birds. 

## Choosing between dismo, biomod2 and sdm 

The dismo package offers single models such as Maxent, Bioclim and boosted regression trees with clear tutorials. The biomod2 package fits several algorithms and merges them into an ensemble, a weighted blend of predictions. The sdm package also builds ensembles, with compact syntax and built-in testing on held-out data. The older raster package is giving way to terra, so check which one each package expects. 

## Preparing environmental raster layers for prairie species 

Environmental raster layers are grids of values such as temperature, rainfall, land cover or elevation across a region. All layers must share the same extent, resolution and projection before a model can read them together. Strongly correlated variables can distort results, so many workflows drop one layer from each correlated pair. For grassland birds, land cover and grazing or fire layers can matter as much as climate. 

## Questions about species distribution models in R 

### Which R package should I use for species distribution modeling? 

The right R package for species distribution modeling depends on whether you need one model or an ensemble. The dismo package suits learners who want to see how a single method such as Maxent works. Projects that compare several algorithms may suit biomod2 or sdm, which both produce combined predictions. 

### How many occurrence records do I need for a species distribution model? 

No fixed number of occurrence records suits every species distribution model. The required sample depends on the species range, the number of predictors and the chosen algorithm. [Rare prairie birds](/articles/rare-birds-of-grasslands-a-quiet-guide-to-unusual-prairie-sightings/) with few records call for simple models with only a handful of variables. 

### Can I use presence-only data from birding checklists? 

Yes, presence-only data from birding checklists can feed species distribution models in R. Methods such as Maxent compare known sightings with background points drawn across the study area. Observer effort is uneven, so background points should reflect where birders actually search. Complete checklists that list every species seen also let you infer non-detections. 

### How do I check if a species distribution model is reliable? 

A species distribution model is checked by testing its predictions on records it did not see during fitting. Scores such as AUC, short for area under the curve, rate how well presences are ranked above background. Spatially separated test data give a stricter check than random splits of the same records. A suitability map shows potential habitat, not confirmed presence, so field checks remain valuable.
