Spatial machine learning

Features, spatial cross-validation, prediction rasters and the area a model can honestly speak for.

A prediction raster covering more ground than the training samples can honestly speak for. the map covers more ground than the model can speak forinside the training rangethe model has seen thispredicted anywayno support, same colours?A random train/test split scores this whole rectangle; a spatial one scores only the left of it

Machine learning on spatial data breaks two assumptions at once. Rows are not independent, because neighbouring observations are nearly the same observation; and prediction usually extends over ground the training data never covered.

Both show up as an accuracy figure that is too good. A random train/test split puts a sample and its neighbour on opposite sides of the split, so the model is scored on data it has effectively seen — block or spatial cross-validation is what measures whether it transfers. Adding raw coordinates as features makes this worse in an interesting way: they genuinely capture structure the covariates miss, and they are also a lookup table for this study area and meaningless outside it.

The pages below cover what the effective sample size actually is, how to split and validate spatially, how to build a prediction raster, and how to state the area a model can honestly speak for.

Learning paths run through this topic too — see the end of this page.

🧭 Start with the concepts

The ideas the how-to guides below assume you already have.

⚙️ Then do the task

Step-by-step walkthroughs with code you can copy and adapt.

Show every how-to guide in this topic

🔧 When it breaks

The errors this topic produces, with the cause explained rather than just the command.

Related topics

Subjects that keep coming up alongside this one, most overlap first.

Keep browsing

Spatial machine learning sits in Modelling & prediction. Every topic on the site is listed on the topics index.