Learn R Programming

gchartsmap (version 1.0.1)

gchart_generate_countries: Generate Google Charts spatial data for all countries

Description

This function queries 'Google Charts' resources to identify countries for which geographical data is available, and generates the simple features for local use.

Usage

gchart_generate_countries(
  countries = "all",
  server = "https://www.gstatic.com/charts/geochart/10/mapfiles/",
  cache = gchart_get_cache_path(),
  verbose = TRUE
)

Value

Returns a simple features `data.frame` with class `sf`, representing the spatial data for all countries from the Google Charts servers, using the WGS84 (epsg = 4326) coordinate reference system. You need to first run `gchart_set_cache()` so the package knows where to store the downloaded data.

Arguments

countries

Which countries to process. Defaults to "all". Use country codes from gchartsmap::gchart_countries()

server

Google geochart server to access.

cache

Path to store downloaded data.

verbose

Whether to show messages during processing.

Examples

Run this code

library(package = "gchartsmap")

# set the cache path to your system's cache path
gchartsmap::gchart_set_cache(path = tempdir())

# GET and process all countries
gchartsmap::gchart_generate_countries(countries = "GT")

# clean up
list.files(
  tempdir(), all.files = TRUE, full.names = TRUE, recursive = TRUE
)

Run the code above in your browser using DataLab