# One labelled Sinop place, every year

A place of the sits book's Sinop CSV in every agricultural year of a recorded MODIS run: each year's distance to the year its label holds for, against its label's threshold. A distance is a measure; no year gets a label.

[From step 4 of From a cube to labelled samples](/time-series.md).

In the sits book: [Basic operations on image time series](https://e-sensing.github.io/sitsbook/ts_basics.html) and [Machine learning algorithms for image time series](https://e-sensing.github.io/sitsbook/cl_machinelearning.html).

Choose a place and see which years look like its labelled year, against the threshold of its own label.

## The figure

Recorded Sinop MODIS series, imported into this site's pipeline; separate from the journey's Cerrado samples. A shaded row differs from the labelled year by more than the threshold: a measure, not a label.

Recorded Sinop MOD13Q1-6.1 from MPC, tile h12v10, separate from the journey's Cerrado samples · sits_get_data() at 18 places, 16 years of 23 dates. One place of the sits book's samples_sinop_crop.csv at a time, in each of its 16 agricultural years: a chart of 2013–14, the year its label holds for, then a row per year with its series, the labelled year dashed behind it, and its distance to the labelled year as a bar on one scale for every place, against the threshold of the place's label. A year over the threshold is shaded: it differs. A distance is a measure; no year but the labelled one carries a label. Previous and next buttons and a list choose the place.

It opens on place 7, labelled Soy corn for 14 Sep 2013 to 29 Aug 2014. The threshold of Soy corn is 0.79 (28 pairs).

| Year    | Distance to 2013–14 | Against the threshold          |
| ------- | ------------------- | ------------------------------ |
| 2000–01 | 1.23                | over the threshold, it differs |
| 2001–02 | 1.21                | over the threshold, it differs |
| 2002–03 | 0.76                | at or under the threshold      |
| 2003–04 | 0.94                | over the threshold, it differs |
| 2004–05 | 1.02                | over the threshold, it differs |
| 2005–06 | 0.75                | at or under the threshold      |
| 2006–07 | 1.06                | over the threshold, it differs |
| 2007–08 | 0.82                | over the threshold, it differs |
| 2008–09 | 0.55                | at or under the threshold      |
| 2009–10 | 0.90                | over the threshold, it differs |
| 2010–11 | 1.71                | over the threshold, it differs |
| 2011–12 | 1.05                | over the threshold, it differs |
| 2012–13 | 1.08                | over the threshold, it differs |
| 2013–14 | 0.00                | the labelled year              |
| 2014–15 | 0.76                | at or under the threshold      |
| 2015–16 | 0.78                | at or under the threshold      |

### About this recorded run

Every year here, 2013–14 included, comes from one remote collection, read by sits_get_data() at the 18 places of samples_sinop_crop.csv and recorded.

- **Collection.** MOD13Q1-6.1 from MPC (Microsoft Planetary Computer). Its search found 2,097 files of two platforms, Terra and Aqua; sits_select() kept the dates of those whose path holds /MOD13Q1/ (Terra), 370 dates. The same places read from the Brazil Data Cube's MOD13Q1-6.1 in 2012–13 (9 places) and 2013–14 (2 places): 506 values compared, every one equal.
- **Region.** A box around the CSV's places, longitude −55.75 to −55.37 and latitude −11.79 to −11.58 with a margin, in tile h12v10.
- **Places.** The 18 rows of samples_sinop_crop.csv, in EVI and NDVI; the image draws NDVI.
- **Self-check.** 1,152 values (2 dates a year) were compared with a direct read of the same files: 998 that sits kept are equal, and 154 that sits dropped where the cloud band flags them or the value is missing or out of range, then filled.
- **The labelled year.** The book's local Sinop files are MODIS Collection 6 (MOD13Q1.A2013257.h12v10.006.2015268074234.hdf), opened as MOD13Q1-6.1; the remote file of the same date is Collection 6.1 (MOD13Q1.A2013257.h12v10.061.2021240012413_250m_16_days_NDVI.tif). So 2013–14 here is the remote version: only 3 of 414 NDVI values are equal, and the largest difference at a place runs from 0.02 to 0.39.
- **Distance and threshold.** Euclidean distance between the NDVI series of the year and of the labelled year, both from the remote collection. Threshold: per label, the median of the Euclidean distances between the NDVI series of every two points of that label in the labelled year (remote).

| Year    | First date  | Last date   | Dates |
| ------- | ----------- | ----------- | ----- |
| 2000–01 | 13 Sep 2000 | 29 Aug 2001 | 23    |
| 2001–02 | 14 Sep 2001 | 29 Aug 2002 | 23    |
| 2002–03 | 14 Sep 2002 | 29 Aug 2003 | 23    |
| 2003–04 | 14 Sep 2003 | 28 Aug 2004 | 23    |
| 2004–05 | 13 Sep 2004 | 29 Aug 2005 | 23    |
| 2005–06 | 14 Sep 2005 | 29 Aug 2006 | 23    |
| 2006–07 | 14 Sep 2006 | 29 Aug 2007 | 23    |
| 2007–08 | 14 Sep 2007 | 28 Aug 2008 | 23    |
| 2008–09 | 13 Sep 2008 | 29 Aug 2009 | 23    |
| 2009–10 | 14 Sep 2009 | 29 Aug 2010 | 23    |
| 2010–11 | 14 Sep 2010 | 29 Aug 2011 | 23    |
| 2011–12 | 14 Sep 2011 | 28 Aug 2012 | 23    |
| 2012–13 | 13 Sep 2012 | 29 Aug 2013 | 23    |
| 2013–14 | 14 Sep 2013 | 29 Aug 2014 | 23    |
| 2014–15 | 14 Sep 2014 | 29 Aug 2015 | 23    |
| 2015–16 | 14 Sep 2015 | 28 Aug 2016 | 23    |

| Label    | Threshold | Pairs |
| -------- | --------- | ----- |
| Cerrado  | 1.23      | 3     |
| Forest   | 0.23      | 3     |
| Pasture  | 0.60      | 6     |
| Soy_Corn | 0.79      | 28    |

### How it was made

1. Read the Sinop run record: The pipeline verifies the recorded Sinop MODIS run. Its original settings and historical checks stay recorded; exporting it does not repeat the upstream queries.
2. Write the files: The pipeline writes the files the website reads, each with a record of its sources and of how closely a rerun repeats it.

### Reproducibility details

- A rerun on aarch64-apple-darwin23 gave the same files, byte for byte.

Every step of the pipeline:

1. Identifies the frozen Sinop run record. `"records/sinop/54e558b03b21c63b19975fe6ba57499e6cd9056edc1d0c4b17066521c32355f9.rds"`
2. Validates the recorded Sinop bytes, settings and axes. `samples_sinop_read(sinop_record_file, list(kind = "recorded", path = "records/sinop/54e558b03b21c63b19975fe6ba57499e6cd9056edc1d0c4b17066521c32355f9.rds", bytes = 3902468, sha256 = "54e558b03b21c63b19975fe6ba57499e6cd9056edc1d0c4b17066521c32355f9"))`
3. Writes the recorded Sinop metadata and historical checks. `site_write_json(samples_sinop_json(sinop_record), "../web/src/data/series-years.json")`
4. Writes the recorded point/year/band/date values. `samples_sinop_write(samples_sinop_arrays(sinop_record)[["years"]], "../web/public/data/series-years-years.bin", "int16")`

The files:

- `series-years.json`: SHA-256 `3d7c36679bc522ee19086c2d83c8457d3ce2bfff32dfbbb925f0ca6b39a32a21`. A rerun on aarch64-apple-darwin23 gave the same file, byte for byte.
- `series-years-years.bin`: SHA-256 `6745b1104ebc0f94a9d825fa8071d91d186e44b50811f34dc7fba0fed2672da0`. A rerun on aarch64-apple-darwin23 gave the same file, byte for byte.

To make them again: `cd pipeline && Rscript make.R`.

## What to try

1. **Compare labels.** Step through the places with the arrows or the list: the line over the chart names each place's label, and the threshold under the bars changes with it. See how many rows stay alike for places with different labels.
2. **Read a shaded year.** In a shaded row the dashed line is the labelled year: the shape that year departs from. The series says that it differs, not what happened.
3. **Find the widest gap.** The longest bar of a place is its least alike year; the bars of every place share one scale.
