Skip to content

Brazil Soy 2025

View or edit on GitHub

This page is synchronized from trase/products/analysis/explainers/brazil_soy_2025/README.md. Last modified on 2026-11-02 10:41 CET by dependabot[bot]. Please view or edit the original file there; changes should be reflected here after a midnight build (CET time), or manually triggering it with a GitHub action (link).

Brazilian soy exports and deforestation (explainer, January 2025)

A later reproduction of the charts in the Trase explainer Brazilian soy exports and deforestation, published 28 January 2025, from the SEI-PCS Brazil soy v2.7.0 results. The explainer was not originally written here: it was published with Datawrapper charts built on v2.6 of the data for 2022.

SQL queries support a Metabase -> Datawrapper workflow

The data for the charts are constructed in files sql/*.sql. This is to support a workflow where by the queries are run in Metabase, then the results copied to Datawrapper.

Each file is a question in the Metabase collection Explainer 2.7.0, run on the Trase.Earth (BigQuery) database. sync_sql_queries_with_metabase.py copies the queries between the two. Each file's first line links to its question, and the script needs a Metabase API key in your user-level trase.env (TRASE_METABASE__API_KEY=mb_...): its docstring explains how to get one and where the file is.

cd trase/products/analysis/explainers/brazil_soy_2025
python sync_sql_queries_with_metabase.py pull   # Metabase -> sql/*.sql
python sync_sql_queries_with_metabase.py push --dry-run   # check, and say what push would do
python sync_sql_queries_with_metabase.py push   # sql/*.sql -> Metabase

Both overwrite the other side without checking it, so pull before you edit, and use git (git diff sql/) to see what a pull changed. For checking the history of changes witin the Metabase question UI, click on the (i) 'More information' icon on the top right of its page, and select the History tab.

Updating the explainer after a data release

  1. Pull any edits made in Metabase: python sync_sql_queries_with_metabase.py pull.
  2. For each chart, run its question in the Metabase collection and download the results (CSV): Metabase shows at most 2,000 rows on screen, and the hotspots question has more.
  3. Paste or upload each download into its chart in Datawrapper - Brazil soy - 2026 Explainer, and republish the chart.
  4. Re-render the notebook (quarto render brazil_soy_exports_and_deforestation.qmd) and commit the result.

The hotspot and trader queries (sql/03_*, sql/05_*) are written for 2025 alone: to move the explainer to another year, change the year in their WHERE clauses and YEAR in the notebook.

Source data

The queries read the SEI-PCS Brazil soy v2.7.0 data package as deployed to review.trase.earth, from BigQuery:

trase-396112.review_trase_earth.supply_chains    -- model_name = 'brazil_soy_v2_7_0'

Brazil's soy production and planted area are IBGE figures from Trase's soy indicators (SOY_TN and SOY_AREA at country level):

trase-396112.review_trase_earth.spatial_metrics

The map of hotspots also reads municipality boundaries:

s3://trase-storage/brazil/spatial/boundaries/ibge/old/boundaries municipalities/MUNICIPALITIES_BRA.geojson

Rendering the notebook therefore needs Google Cloud credentials that can query the trase-396112 project (gcloud auth application-default login) as well as AWS credentials for the boundaries.