Writing Space & geospatial

How a model sees a satellite image

Hand a satellite image to a classifier and it hands back a map: water here, crops there, city in between. The natural way to describe that is to say the model looked at the picture. It did not, and most of what such a model gets right and wrong follows from what it was actually given.

So I took one real scene, trained a small land-cover model on it four times with four different inputs, and put the results on this page. Everything below is the same 14.4 by 9.6 kilometres of eastern Washington.

Six photographs of the same place

The scene is Pasco, Washington, as Sentinel-2A saw it on 8 July 2021. The Columbia runs across the middle and the Snake joins it at the lower right. Kennewick is south of the river, the Tri-Cities airport is at the upper left, and the green discs are fields under centre-pivot irrigation, each one the reach of a sprinkler arm turning about a well.

A phone camera records three numbers per pixel. Sentinel-2 records thirteen, each through a different filter, and most of them at wavelengths nobody can see. I kept six: blue, green and red, then near infrared (NIR) and two shortwave infrared bands (SWIR). Each number is a reflectance, the fraction of sunlight at that wavelength that the ground sent back. Every pixel is 20 metres on a side, so the scene is 720 by 480 of them.

A band is a greyscale photograph. A colour image is a decision about which three bands to send to the red, green and blue of your screen, and “true colour” is only the decision that happens to match your eyes.

The marker starts on a crop circle. That pixel reflects about 4% of the red light falling on it and more than half of the near infrared. Chlorophyll absorbs red to drive photosynthesis, and the spongy cell structure inside a healthy leaf scatters near infrared straight back out. Nothing else in the scene has that shape, which is why vegetation mapping has leaned on those two bands since the 1970s. The shortwave bands respond mostly to water, in leaves and in soil: wet things are dark there, dry mineral things are bright.

The model never gets the picture

The simplest land-cover model, and still a very common one, classifies each pixel on its own. Its input is one row of six numbers. It is not told where the pixel is or what sits beside it. The scene, as far as that model is concerned, is a table with 345,600 rows and six columns.

That has a consequence you can test. Shuffle the pixels into a random order and you have destroyed the image. You have not changed the table at all, only the order of its rows, so a per-pixel model would return exactly the same answer for every pixel.

This is the useful way to think about adding a band. It does not sharpen the picture. It adds a column, which is another axis along which two kinds of ground that used to sit on top of each other might come apart. Whether they do is an empirical question about those two kinds of ground.

Painting the map

A classifier needs labels to learn from, and nobody walked this scene for me. I used ESA WorldCover 2021, a global 10 metre land-cover map, resampled to the same 20 metre grid. Six of its classes occur here in any quantity. The model is a random forest: 120 decision trees, each a long chain of questions of the form “is near infrared above 0.31?”, voting on the answer.

I cut the scene into 24 blocks of 2.4 kilometres, trained on pixels from 16 of them and scored on the other 8, for the reasons in Your validation set is next door. Then I trained it again with more columns each time.

With only the three visible bands, the model agrees with the reference on 68.7% of held-out pixels. Near infrared takes that to 71.7%, and the two shortwave bands to 75.3%. The gain is real and it lands where the physics says it should. Crops go from 57% recovered to 70%, trees from 45% to 59%, and water, which was already easy, from 95% to 98%.

I expected more. The infrared composite makes the scene look solved, and six and a half points is not solved. So I gave the model all ten of Sentinel-2’s 10 and 20 metre bands, including the three red-edge bands designed for vegetation. It scored 75.6%. The curve had flattened.

What another band cannot fix

Three things are left in the disagreement map, and none of them is a shortage of wavelengths.

Different classes made of the same material. Bare ground is the model’s worst class by a distance: with all six bands it recovers 24% of it and calls two thirds of it built-up. Gravel, concrete, a dirt lot and a flat commercial roof are all dry mineral surfaces. They are different land cover and nearly the same spectrum. What tells them apart is that one of them has straight edges and a car park, which is not in the row.

Pixels that are several things at once. Twenty metres of a residential street holds part of a roof, a strip of lawn, a tree and some asphalt. The sensor reports one blended spectrum for all of it and the label reports whichever class won the vote. Look at the neighbourhoods either side of the river in the disagreement view: they stay speckled whatever the model is given.

Labels that know something the image does not. WorldCover was built from a full year of Sentinel-1 radar and Sentinel-2 imagery. It calls the pale fields in among the green discs cropland, presumably because it watched them be green at some other point in the season. My model has one afternoon in July, on which those fields are dry, and it calls them grass. On the evidence it was given, that is a reasonable answer.

On the labels: WorldCover is itself the output of a model, and its own validation report puts its overall accuracy at 76.7% against independent reference data. So every number in this post measures agreement with another map. That is worth saying plainly, because near the top of the range I can no longer tell which of the two maps is the one that is wrong.

Giving it neighbours

The fourth option in the figure breaks the rule I started with. For each pixel I added the mean and the standard deviation of every band over the 5 by 5 window around it, so the row grows from six numbers to eighteen and now says something about texture: a smooth field and a busy street can have the same average colour and very different spread.

Agreement rises to 78.1%, and the map visibly changes character. The speckle inside fields and across the river goes, because a pixel is no longer free to disagree with everything around it. This is also the point at which shuffling would start to matter. A convolutional network is the same move made properly: instead of two summary statistics I chose by hand, it learns which arrangements of neighbouring pixels are worth noticing, at several scales. That is the sense in which such a model does see an image.

Bare ground still does not improve. A 100 metre window is too small to contain the shape of a car park.

How I scored it, and what a lazier split says

Had I held out pixels at random instead of whole blocks, the six-band model would have scored 78.0% rather than 75.3%. The gap is smaller than the ones spatial leakage usually produces, and the reason is instructive: a per-pixel model has no access to location, so it cannot memorise a neighbourhood. It can still benefit from the test pixel’s neighbour, cut from the same field on the same day, being in the training set. Nearly three points of flattery is about what one more band was worth.

Why I care about this

The questions people actually pay to have answered about land are rarely “what class is this pixel”. They are closer to “how much of this parcel is paved” or “has this site been cleared since last year”, and they are asked about one address at a time. A map that is 78% right on average says very little about a given parcel until you know which kind of wrong is likely there, and the failures above are not spread evenly. They pile up on exactly the surfaces commercial property is made of.

So before trusting a land-cover product I now ask three things of it. What was each pixel’s row: one date or a season, one pixel or a neighbourhood? What were the labels, and how good were they? And was it scored somewhere it had not already seen? The answers are usually in the documentation and usually explain the map better than the map does. It is the same argument I made in Observation, estimate, inference: the number is only as good as the evidence behind it, so keep the evidence attached.

The model did not see a river with a city on it. It saw 345,600 rows, and it did rather well considering.

Method

Sentinel-2A Level-2A surface reflectance, tile 11TLM, relative orbit 113, sensed 8 July 2021 at 19:01 UTC, read from the public cloud-optimised archive on AWS. Bands 2, 3, 4 and 8 were averaged from 10 to 20 metres to match bands 11 and 12. WorldCover 2021 v200 was reprojected to the same grid by majority vote; shrubland and wetland, 23 pixels between them, were left unlabelled. Each random forest has 120 trees with a minimum leaf size of 5 and was fitted with scikit-learn on 60,000 pixels drawn from the training blocks. The images in the figures are JPEG-compressed, so the reflectances they display are close to the values the models were trained on, not identical to them.

References

  1. M. Drusch et al. “Sentinel-2: ESA’s Optical High-Resolution Mission for GMES Operational Services.” Remote Sensing of Environment, 120, 2012, pp. 25–36. The instrument and its thirteen bands.
  2. D. Zanaga et al. ESA WorldCover 10 m 2021 v200. Zenodo, 2022. doi:10.5281/zenodo.7254221. The reference labels.
  3. ESA WorldCover consortium. WorldCover Product Validation Report, version 2.0, 2022. The source of the 76.7% figure.
  4. C. J. Tucker. “Red and photographic infrared linear combinations for monitoring vegetation.” Remote Sensing of Environment, 8(2), 1979, pp. 127–150. Why red and near infrared, together.
  5. L. Breiman. “Random Forests.” Machine Learning, 45, 2001, pp. 5–32.
  6. M. Belgiu, L. Drăguţ. “Random forest in remote sensing: A review of applications and future directions.” ISPRS Journal of Photogrammetry and Remote Sensing, 114, 2016, pp. 24–31.
  7. C. F. Brown et al. “Dynamic World, Near real-time global 10 m land use land cover mapping.” Scientific Data, 9, 2022, article 251. Land cover from a convolutional network, for comparison with everything above.
All writing Get in touch