Before this: From series to embeddings
From a cube to labelled samples
How does a place in a cube become a sample whose label we know?
Open a labelled sample from the book. Then follow one place through a cube, and compare the optical series and embeddings of the Cerrado's labelled samples.
Step 01 of 5
What is in a labelled sample?
The book reads the labelled samples of Mato Grosso from Hugging Face.
The book's code
samples_matogrosso_mod13q1 <- sits_from_hf(
repo = "e-sensing/samples_book",
file = "samples_matogrosso_mod13q1.parquet",
type = "dataset"
)Where the sits book writes this call: ts_basics.qmd, lines 61–65
The book begins with 1,837 samples of Mato Grosso. A sample names a place, a period and a label.
The last cell holds the measurements through that period: a time series.
Many places carry this label. Drawn together, their series show what they share and how much they differ.
sits_patterns() fits one curve to each class. It summarizes what these samples share.
Choose a band or a class. These are the book’s MODIS samples, collected in different years.
Published MODIS · 1,837 recorded samples
- longitude
- -57.794
- latitude
- -9.7573
- label
- Pasture
- cube
- bdc_cube
- start_date
- 2006-09-14
- end_date
- 2007-08-29
- time_series
- closed
Try it: Patterns of labelled samples
Step 02 of 5
How does one place become a time series?
Here sits reads one place through the months of the Cerrado cube.
The book's code
series <- sits_get_data(cube = raster_cube,
samples = sample_latlong)Where the sits book writes this call: ts_basics.qmd, lines 490–491
The book’s call uses Sinop. Here we ran it on one point in the cached Cerrado window.
Now the Cerrado, with Landsat images. The marked place lies inside the small window.
The same pixel is present in every month’s image.
Read down the column: 24 months in 6 bands.
sits_get_data() returned this row. Its label is NoClass because we supplied only a location.
Cached Cerrado window · BDC · LANDSAT-OLI-16D
Loading rgb-months.png (1.4 MB).
Step 03 of 5
Do all places behave the same?
The book reads recorded optical series for labelled places across the Cerrado.
The book's code
labelled_samples <- sits_from_hf(
repo = "e-sensing/samples_cerrado",
file = "labelled_samples_cerrado.parquet",
type = "dataset"
)Where the sits book writes this call: emb_example.qmd, lines 551–555
sits_from_hf() reads series that were already extracted; their original extraction is undocumented.
These places lie across the Cerrado. They are outside the small window; the map shows both footprints.
This is one place’s recorded NIR08 series. We read it from the published sample file.
Another place, another curve. Their Euclidean distance in NIR08 measures the difference.
Choose a place or a band. A shape alone is not a supplied label.
Loading labelled-sample-points.bin (80 kB).
Longitude/latitude, equirectangular, no basemap · Study window drawn larger than its true 7.7 km
Step 04 of 5
Where does a sample's label come from?
A label belongs to a place for a stated period.
The published sample already carries this label. The curve did not assign it.
These regional records carry 11 labels. The comparison keeps the same 4,443 samples.
The label holds for this period. Open the Sinop example to compare other years.
Loading labelled-sample-points.bin (80 kB).
A · Place 5
Longitude/latitude, equirectangular, no basemap · Study window drawn larger than its true 7.7 km
Loading labelled-samples-NIR08.bin (853 kB).
Step 05 of 5
What changes when a sample is encoded?
The book passes the samples’ optical series to the encoder.
The book's code
samples_lejepa <- sits_encode(
data = labelled_samples_red,
encoder = lejepa_encoder,
multicores = 8,
gpu_memory = 16,
batch_size = 512,
verbose = TRUE
)Where the sits book writes this call: emb_example.qmd, lines 601–608
The book encodes a random fraction of its samples. Here the pipeline encoded the 4,443 samples valid from 2017-01-01, drawn per class with a fixed seed.
This is the sample’s recorded NIR08 series, one of the 6 bands the encoder reads.
sits_encode() reads all 6 bands over 24 months. The encoder connection here is a diagram.
64 values come back. The location, valid period and supplied label stay with the sample.
Switch forms for the same samples. One axis follows months; the other follows dimensions.
Compare one class in either form. Embedding dimensions do not mark seasons.
Loading labelled-sample-points.bin (80 kB).
Longitude/latitude, equirectangular, no basemap · Study window drawn larger than its true 7.7 km
Optical form: the recorded NIR08 series of A, Place 5, over its monthly dates.
Loading labelled-samples-NIR08.bin (853 kB).