dblogr.com/

Global Agricultural Land Use

Graphs of global agricultural land use with FAO data


Data

# devtools::install_github("derekmichaelwright/agData")
library(agData)
# devtools::install_github("hrbrmstr/waffle")
library(waffle)

Prepare Data

# Prep data
myColors <- c("darkred", "darkgreen", "darkorange", "darkblue", "steelblue" )
myItems1 <- c("Agricultural land", 
             "Land under perm. meadows and pastures",
             "Cropland")
myItems2 <- c("Total Agricultural Land", "Meadows & Pastures", "Crop Land")
#
pp <- agData_FAO_Population %>% 
  filter(Measurement == "Total") %>%
  select(Area, Year, Population=Value)
d1 <- agData_FAO_LandUse %>% 
  filter(Item %in% myItems1) %>%
  left_join(pp, by = c("Area","Year")) %>%
  mutate(Item = plyr::mapvalues(Item, myItems1, myItems2),
         Item = factor(Item, levels = myItems2),
         AreaPerPerson = Value / Population)
d2 <- agData_FAO_LandUse
#
myCaption <- "www.dblogr.com/ or derekmichaelwright.github.io/dblogr/ | Data: FAOSTAT"

Agricultural Area

Total

# Prep data
xx <- d1 %>% filter(Area %in% "World")
# Plot 
mp1 <- ggplot(xx, aes(x = Year, y = Value / 1000000000, color = Item)) +
  geom_line(size = 1.5, alpha = 0.7) +
  facet_wrap(Item ~ ., scales = "free_y") +
  scale_color_manual(values = myColors) +
  theme_agData(legend.position = "none") +
  labs(title = "A)", y = "Billion Hectares", x = NULL, caption = "")
mp2 <- ggplot(xx, aes(x = Year, y = Value / 1000000000, fill = Item)) +
  geom_col(size = 1.5, alpha = 0.7) +
  facet_wrap(Item ~ ., scales = "free_y") +
  scale_fill_manual(values = myColors) +
  theme_agData(legend.position = "none") +
  labs(title = "B)", y = "Billion Hectares", x = NULL, caption = myCaption)
mp <- ggarrange(mp1, mp2, ncol = 1, nrow = 2)
ggsave("farmland_world_1_01.png", mp, width = 10, height = 7)

Per Person

# Prep Data
xx <- d1 %>% filter(Area %in% "World", Item != myItems2[1])
y1_min <- 0
y1_max <- max(xx$Value)
y2_min <- min(xx$AreaPerPerson)
y2_max <- max(xx$AreaPerPerson)
xx <- xx %>% 
  mutate(APP_scaled = (AreaPerPerson - y2_min) * (y1_max - y1_min) / 
                                 (y2_max - y2_min) + y1_min )
mySA <- sec_axis(~(. - y1_min) * (y2_max - y2_min) / (y1_max - y1_min) + y2_min, 
                 name = "Hectares Per Person (lines)")
# Plot Data
mp <- ggplot(xx, aes(x = Year, y = Value, fill = Item)) + 
  geom_col(position = "dodge", color = "black", alpha = 0.6, lwd = 0.1) +
  geom_line(aes(y = APP_scaled, color = Item), size = 2, alpha = 0.9) +
  scale_x_continuous(breaks = seq(1960, 2020, by = 10)) +
  scale_y_continuous(breaks = 0:3 * 1000000000, labels = 0:3, 
                     sec.axis = mySA) +
  scale_fill_manual(name = NULL, values = myColors[2:3]) +
  scale_color_manual(name = NULL, values = myColors[2:3]) +
  theme_agData(legend.position = "bottom") +
  labs(title = "Global Agricultural Area", x = NULL,
       y = "Billion Hectares (bars)", caption = myCaption)
ggsave("farmland_world_1_02.png", mp, width = 6, height = 4)

Regions

Bar

# Prep Data
xx <- d1 %>% filter(Year == 2019, Area %in% agData_FAO_Region_Table$Region)
# Plot Data
mp <- ggplot(xx, aes(x = Area, y = Value / 1000000, fill = Area)) + 
  geom_col(color = "black", alpha = 0.7) +
  facet_wrap(Item ~ ., scales = "free_y") +
  scale_fill_manual(name = NULL, values = myColors) +
  theme_agData(legend.position = "none",
               axis.text.x = element_text(angle = 45, hjust = 1)) + 
  labs(title = "Global Agricultural Area", x = NULL, 
       y = "Million Hectares", caption = myCaption)
ggsave("farmland_world_1_03.png", mp, width = 8, height = 3.5)

Waffle

# Prep data
xx <- d1 %>% 
  filter(Year == 2019, Area %in% agData_FAO_Region_Table$Region) %>% 
  mutate(Value = round(Value / 10000000))
x1 <- xx %>% filter(Item == myItems2[1])
x2 <- xx %>% filter(Item != myItems2[1])
# Plot
mp1 <- ggplot(x1, aes(fill = Area, values = Value)) +
  geom_waffle(color = "white", n_rows = 15, alpha = 0.7, na.rm = T) +
  scale_fill_manual(name = NULL, values = myColors) +
  facet_grid(. ~ Item, scales = "free", space = "free") +
  theme_agData_pie(legend.position = "bottom") +
  labs(title = "10,000,000 Hectares of land")
mp2 <- ggplot(x2, aes(fill = Area, values = Value)) +
  geom_waffle(color = "white", n_rows = 15, alpha = 0.7, na.rm = T) +
  scale_fill_manual(name = NULL, values = myColors) +
  facet_grid(. ~ Item, scales = "free", space = "free") +
  theme_agData_pie(legend.position = "none") +
  labs(caption = myCaption)
mp <- ggarrange(mp1, mp2, ncol = 1, nrow = 2, heights = c(1,0.8))
ggsave("farmland_world_1_04.png", mp, width = 5, height = 7)

SubRegions

# Prep Data
xx <- d1 %>% 
  filter(Year == 2019, Item != myItems2[1],
         Area %in% agData_FAO_Region_Table$SubRegion) %>%
  left_join(agData_FAO_Region_Table, by = c("Area"="SubRegion")) %>%
  arrange(desc(Value)) %>%
  mutate(Area = factor(Area, levels = unique(Area)) )
# Plot Data
mp <- ggplot(xx, aes(x = Area, y = Value / 1000000, fill = Region)) + 
  geom_col(color = "black", alpha = 0.7) +
  facet_grid(Item ~ Region, scales = "free", space = "free_x") +
  scale_fill_manual(name = NULL, values = myColors) +
  theme_agData(legend.position = "none",
               axis.text.x = element_text(angle = 45, hjust = 1)) + 
  labs(title = "Cropland", x = NULL,
       y = "Million Hectares", caption = myCaption)
ggsave("farmland_world_1_05.png", mp, width = 8, height = 5)

Top 20 Countries

Agricultural Land

# Prep Data
xx <- d1 %>% 
  filter(Item == myItems2[1], Year == 2019) %>%
  region_Info() %>%
  filter(Area %in% agData_FAO_Country_Table$Country) %>%
  arrange(desc(Value)) %>%
  slice(1:20) %>%
  mutate(Area = factor(Area, levels = unique(Area)))
# Plot Data
mp <- ggplot(xx, aes(x = Area, y = Value / 1000000, fill = Region)) + 
  geom_col(color = "black", alpha = 0.7, lwd = 0.3) +
  scale_fill_manual(name = NULL, values = myColors) +
  scale_x_discrete(limits = rev(levels(xx$Area))) +
  scale_y_continuous(breaks = seq(0, 500, by = 100)) +
  theme_agData(legend.position = "bottom") + 
  coord_flip(ylim = c(0.02, max(xx$Value) / 1000000)) +
  labs(title = "Agricultural Area", x = NULL,
       y = "Million Hectares", caption = myCaption)
ggsave("farmland_world_3_01.png", mp, width = 6, height = 4)

Cropland

# Prep Data
xx <- d1 %>% 
  filter(Item == myItems2[3], Year == 2019) %>%
  region_Info() %>%
  filter(Area %in% agData_FAO_Country_Table$Country) %>%
  arrange(desc(Value)) %>%
  slice(1:20) %>%
  mutate(Area = factor(Area, levels = unique(Area)))
myAreas <- levels(xx$Area)
# Plot Data
mp <- ggplot(xx, aes(x = Area, y = Value / 1000000, fill = Region)) + 
  geom_col(color = "black", alpha = 0.7, lwd = 0.3) +
  scale_fill_manual(name = NULL, values = myColors) +
  scale_x_discrete(limits = rev(levels(xx$Area))) +
  theme_agData(legend.position = "bottom") + 
  coord_flip(ylim = c(0.02, max(xx$Value) / 1000000)) +
  labs(title = "Cropland", x = NULL,
       y = "Million Hectares", caption = myCaption)
ggsave("farmland_world_3_02.png", mp, width = 6, height = 4)

Organic Area

Area

# Prep Data
xx <- d2 %>% 
  filter(Item == "Agriculture area certified organic",
         Year == 2019) %>%
  region_Info() %>%
  filter(Area %in% agData_FAO_Country_Table$Country) %>%
  arrange(desc(Value)) %>%
  slice(1:20) %>%
  mutate(Area = factor(Area, levels = unique(Area)))
# Plot Data
mp <- ggplot(xx, aes(x = Area, y = Value / 1000000, fill = Region)) + 
  geom_col(color = "black", alpha = 0.7, lwd = 0.3) +
  scale_fill_manual(name = NULL, values = myColors) +
  scale_x_discrete(limits = rev(levels(xx$Area))) +
  theme_agData(legend.position = "bottom") +
  coord_flip(ylim = c(0.0009, max(xx$Value) / 1000000)) +
  labs(title = "Agricultural Area - Organic", x = NULL,
       y = "Million Hectares", caption = myCaption)
ggsave("farmland_world_3_03.png", mp, width = 6, height = 4)

Percent

# Prep Data
xx <- d2 %>% 
  filter(Item %in% c("Agriculture area certified organic", 
                     "Agricultural land"),
         Year == 2019) %>%
  select(-Measurement, -Unit) %>%
  spread(Item, Value) %>%
  mutate(Value = 100 * `Agriculture area certified organic` / 
           `Agricultural land`) %>%
  region_Info() %>%
  filter(Area %in% agData_FAO_Country_Table$Country) %>%
  arrange(desc(Value)) %>%
  slice(1:20) %>%
  mutate(Area = factor(Area, levels = unique(Area)))
# Plot Data
mp <- ggplot(xx, aes(x = Area, y = Value, fill = Region)) + 
  geom_col(color = "black", alpha = 0.7, lwd = 0.3) +
  scale_fill_manual(name = NULL, values = myColors) +
  scale_x_discrete(limits = rev(levels(xx$Area))) +
  theme_agData(legend.position = "bottom") +
  coord_flip(ylim = c(1.4, max(xx$Value))) +
  labs(title = "Percent of Farmland Certified as Organic",
       y = NULL, x = NULL, caption = myCaption)
ggsave("farmland_world_3_04.png", mp, width = 6, height = 4)

Canada

# Prep Data
xx <- d2 %>% 
  filter(Area == "Canada", Year == 2019, Item != "Forest Carbon") %>%
  arrange(Value) %>%
  mutate(Item = factor(Item, levels = unique(Item)))
# Plot Data
mp <- ggplot(xx, aes(x = Item, y = Value / 1000000, fill = Item)) + 
  geom_col(color = "black", alpha = 0.7, lwd = 0.3) +
  scale_fill_manual(values = agData_Colors) +
  #scale_x_discrete(limits = rev(levels(xx$Item))) +
  theme_agData(legend.position = "none") + 
  coord_flip() +
  labs(title = "Canada", x = NULL,
       y = "Million Hectares", caption = myCaption)
ggsave("farmland_world_3_05.png", mp, width = 6, height = 4)



dblogr.com/


© Derek Michael Wright