Interactive D3.js visualization of agricultural land area (sq. km) across countries. It highlights top growth from 1980–2020 with an add-to-compare line chart (now with Y-axis zoom + vertical pan) and an independent bar chart showing the largest agricultural land holders in 2020.
Live demo
- Amplify URL: https://staging.dw77vepfrd618.amplifyapp.com/
Agricultural land is a key indicator of land use and sustainability. This tool makes it easy to explore long-term trends, compare countries, and zoom/pan the scale to inspect both very large and smaller countries without losing detail.
- Line chart (1980–2020): starts with the 5 biggest growth countries; add any country to compare.
- Y-axis zoom & pan: buttons for zoom in / out / reset, plus Shift + scroll to pan vertically through huge values.
- Ranking bar chart (2020): begins with top 5 countries; add up to 10 to compare (independent from the line chart).
- Tooltips & labels for precise values, responsive SVG, dark UI.
- Vanilla stack: D3 v7 + HTML/CSS/JS (no build step).
- Catalog: World Development Indicators (WDI) — The World Bank
Link: https://datacatalog.worldbank.org/search/dataset/0037712/World-Development-Indicators - Indicator used: Agricultural land (sq. km).
- Temporal focus: 1980–2020 for the line chart; bar chart uses 2020 (or latest available ≤ 2020 as a fallback).
WDI updates periodically; re-run the prep script to refresh the CSV when new data is released.
-
Download WDI CSV package
Go to the WDI catalog page above and download the CSV archive. -
Extract the archive
Unzip it and locateWDICSV.csv(this is the only file you need). -
Create a working folder
Make a folder (e.g.,wdi-agri-land/), copyWDICSV.csvinto it, and placeDataFormation.pythere too. -
Run the data formation script
Requirements: Python 3.9+ andpandas.python3 DataFormation.py
Output: Agriculture_Land_Large.csv in the same folder.
- Move assets for the app
Ensure
Agriculture_Land_Large.csvis deployed with the app and accessible atDataSets/Agriculture_Land_Large.csv(i.e., next toindex.htmlinside aDataSets/folder).
Serve via a simple static server (browsers block file:// CSV requests):
# Python
python3 -m http.server 8000
# or Node
npx http-server -p 8000Then open: http://localhost:8000
Make sure DataSets/Agriculture_Land_Large.csv is in the expected location relative to index.html.
This project is hosted on AWS Amplify (Drag-and-Drop Hosting) and shortened with Bitly.
-
Prepare a folder (e.g.,
site/) containing:site/ index.html DataSets/ Agriculture_Land_Large.csv (any other assets referenced by index.html) -
Zip the contents of
site/(so the ZIP root hasindex.html, notsite/index.html). -
AWS Console → Amplify Hosting → Host your web app → Deploy without Git provider → Drag & drop the ZIP.
-
Wait for status Deployed. The app is now live at
https://staging.dw77vepfrd618.amplifyapp.com/.
Notes: • If you change files later, upload a new ZIP in the same Amplify environment. • If CSV paths 404, verify
DataSets/Agriculture_Land_Large.csvexists in the deployed bundle.
- Create a Bitly account (free).
- Create new link → Long URL:
https://staging.dw77vepfrd618.amplifyapp.com/. - Set a custom back-half:
agrilandviz→ Save. Final short URL: https://bit.ly/agrilandviz
If
agrilandvizis taken, Bitly will ask for a different back-half.
- Buy a domain in Route 53 or use your existing registrar.
- In Amplify → Domain management → Add domain, map
yourdomain.com(andwww) to this app. Amplify will provision HTTPS automatically if the domain is in Route 53.
- Add countries with the input above each chart.
- Line chart Y-zoom: + / − / 100% buttons.
- Line chart Y-pan: hold Shift and scroll.
- Bar chart (2020): add up to 10 countries; selection is independent of the line chart.
- Tooltips show precise values on hover.
- Extracts the Agricultural land (sq. km) indicator from WDI.
- Reshapes to tidy columns:
Country Name,Country Code,Indicator Name,Indicator Code,Year,Agricultural land (sq. km). - Filters 1980–2020 for the line chart; bar chart uses 2020 (or latest ≤ 2020).
- Cleans numeric fields and removes missing rows.
- Outputs
Agriculture_Land_Large.csvconsumed by the D3 app.
- D3.js v7
- Vanilla HTML/CSS/JS
- Data © The World Bank (World Development Indicators) — follow World Bank data terms and attribution.