An introduction and simple demonstration of geodata
Jing Miao
2024-10-24
Introduction
geodata(“Geodata: Download Geographic Data” 2021) is an R package designed to access and work with geographic data. It provides a user-friendly interface for obtaining a variety of geographic datasets from online resources.
Author
Robert J. Hijmans is a professor at the University of California, Davis, with research interests spanning agriculture, biodiversity, climate, data science, and ecology. He is a leading expert in spatial data analysis, focusing on environmental and ecological modeling.
Hijmans is particularly recognized for his significant contributions to the development of R packages for geospatial analysis, including the widely used raster, geodata, and sp packages. His work has greatly enhanced the capabilities of researchers and practitioners in the field, facilitating advanced analyses of spatial data.
Main Functions
getData():
Download various types of geospatial data, such as climate data and elevation data, from different sources
Usage: getData(name, country, path), dataset name (e.g., “worldclim” or landcover”) for name, ISO code for county (optional), and your path to save data for path.
landcover(var, path, …), in here, var should be one of “trees”, “grassland”, “shrubs”, “cropland”, “built”, “bare”, “snow”, “water”, “wetland”, “mangroves”, “moss”.
cropland <-landcover("cropland", path ="E:\\3-24&25 Buffalo\\2024 Fall Course\\GEO 511\\Resource Presentation")building <-landcover("built", path ="E:\\3-24&25 Buffalo\\2024 Fall Course\\GEO 511\\Resource Presentation")
population
population(year, res, path, …), in here, year should be one of 2000, 2005, 2011, 2015, and 2020; res should be 10, 5, 2.5, and 0.5 (minutes of a degree);
pop <-population(year =2020,res =10, path ="E:\\3-24&25 Buffalo\\2024 Fall Course\\GEO 511\\Resource Presentation")
Visualization 1: Cropland from landcover
cropland_raster <-raster(cropland)plot(cropland_raster, main ="Global Cropland Distribution", xlab ="Longitude",ylab ="Latitude",axes =TRUE)
Visualization 2: Built-Up Area from landcover
building_raster <-raster(building)plot(building_raster, main ="Global Built-Up Area Distribution", xlab ="Longitude",ylab ="Latitude",axes =TRUE)
Visualization 3: Population denstity from population
pop_raster <-raster(pop)pop_df <-as.data.frame(pop_raster, xy =TRUE, na.rm =TRUE)# Plot using ggplotggplot(pop_df, aes(x = x, y = y, fill = population_density)) +geom_tile() +scale_fill_viridis_c(name ="Population Density (log)", trans ="log", option ="A")+labs(title ="Global Population Density", x ="Longitude", y ="Latitude") +theme_minimal()