Movatterモバイル変換


[0]ホーム

URL:


Skip to contents

giscoR

giscoR is anR package that provides a simple interface toGISCO data from Eurostat. It allows you to download and work with global and European geospatial datasets — such as country boundaries, NUTS regions, coastlines, and labels — directly inR.

Key features

  • RetrieveGISCO files for countries, regions, and administrative units.
  • Access data at multiple resolutions:60M,20M,10M,03M,01M.
  • Choose from three projections:EPSG 4326,3035, or3857.
  • Works seamlessly withsf objects for spatial analysis.
  • Includescaching for faster repeated access.

Installation

InstallgiscoR fromCRAN:

You can install the development version ofgiscoR with:

# install.packages("pak")pak::pak("rOpenGov/giscoR")

Alternatively, you can installgiscoR viar-universe:

install.packages("giscoR", repos=c("https://ropengov.r-universe.dev","https://cloud.r-project.org"))

Quick Example

This script highlights some features ofgiscoR :

library(giscoR)library(sf)library(dplyr)# Download The Netherlands boundaries at different resolutionsnl_all<-lapply(c("60","20","10","03"),function(r){gisco_get_countries(country="Netherlands", year=2024, resolution=r)|>mutate(res=paste0(r,"M"))})|>bind_rows()glimpse(nl_all)#> Rows: 4#> Columns: 13#> $ CNTR_ID   <chr> "NL", "NL", "NL", "NL"#> $ CNTR_NAME <chr> "Nederland", "Nederland", "Nederland", "Nederland"#> $ NAME_ENGL <chr> "Netherlands", "Netherlands", "Netherlands", "Netherlands"#> $ NAME_FREN <chr> "Pays-Bas", "Pays-Bas", "Pays-Bas", "Pays-Bas"#> $ ISO3_CODE <chr> "NLD", "NLD", "NLD", "NLD"#> $ SVRG_UN   <chr> "UN Member State", "UN Member State", "UN Member State", "UN…#> $ CAPT      <chr> "Amsterdam", "Amsterdam", "Amsterdam", "Amsterdam"#> $ EU_STAT   <chr> "T", "T", "T", "T"#> $ EFTA_STAT <chr> "F", "F", "F", "F"#> $ CC_STAT   <chr> "F", "F", "F", "F"#> $ NAME_GERM <chr> "Niederlande", "Niederlande", "Niederlande", "Niederlande"#> $ geometry  <MULTIPOLYGON [°]> MULTIPOLYGON (((7.208935 53..., MULTIPOLYGON (((7.202794 53.…#> $ res       <chr> "60M", "20M", "10M", "03M"# Plot with ggplot2library(ggplot2)ggplot(nl_all)+geom_sf(fill="#AD1D25")+facet_wrap(~res)+labs(    title="The Netherlands boundaries at different resolutions",    subtitle="Year: 2024",    caption=gisco_attributions())+theme_minimal()

The Netherlands boundaries at different resolutions

Advanced Example: Thematic maps

This example shows a thematic map created with theggplot2 package. The data are obtained via theeurostat package. This follows the approach presented byMilos Popovic inthis post.

We start by extracting the corresponding geographic data:

library(giscoR)library(dplyr)library(eurostat)library(ggplot2)# Get sf objectsnuts3<-gisco_get_nuts(  year=2021,  epsg=3035,  resolution=10,  nuts_level=3)# Get country lines (NUTS 0 level)country_lines<-gisco_get_nuts(  year=2021,  epsg=3035,  resolution=10,  spatialtype="BN",  nuts_level=0)

We now download the data from Eurostat:

# Use eurostatpopdens<-get_eurostat("demo_r_d3dens")|>filter(TIME_PERIOD=="2021-01-01")

Finally, we merge and manipulate the data to create the final plot:

# Merge datanuts3_sf<-nuts3|>left_join(popdens, by="geo")# Breaks and labelsbr<-c(0,25,50,100,200,500,1000,2500,5000,10000,30000)labs<-prettyNum(br[-1], big.mark=",")# Label function used in the plot, mainly for NAslabeller_plot<-function(x){ifelse(is.na(x),"No Data",x)}nuts3_sf<-nuts3_sf|># Cut with labelsmutate(values_cut=cut(values,br, labels=labs))# Palettepal<-hcl.colors(length(labs),"Lajolla")# Plotggplot(nuts3_sf)+geom_sf(aes(fill=values_cut), linewidth=0, color=NA, alpha=0.9)+geom_sf(data=country_lines, col="black", linewidth=0.1)+# Center in Europe: EPSG 3035coord_sf(    xlim=c(2377294,7453440),    ylim=c(1313597,5628510))+# Legendsscale_fill_manual(    values=pal,# Label for NA    labels=labeller_plot,    drop=FALSE, guide=guide_legend(direction="horizontal", nrow=1))+# Themingtheme_void()+# Themetheme(    plot.title=element_text(      color=rev(pal)[2], size=rel(1.5),      hjust=0.5, vjust=-6),    plot.subtitle=element_text(      color=rev(pal)[2], size=rel(1.25),      hjust=0.5, vjust=-10, face="bold"),    plot.caption=element_text(color="grey60", hjust=0.5, vjust=0),    legend.text=element_text(color="grey20", hjust=.5),    legend.title=element_text(color="grey20", hjust=.5),    legend.position="bottom",    legend.title.position="top",    legend.text.position="bottom",    legend.key.height=unit(.5,"line"),    legend.key.width=unit(2.5,"line"))+# Annotate and labslabs(    title="Population density in 2021",    subtitle="NUTS-3 level",    fill="people per sq. kilometer",    caption=paste0("Source: Eurostat, ",gisco_attributions(),"\nBased on Milos Popovic: ","https://milospopovic.net/how-to-make-choropleth-map-in-r/"))

Population density in 2021

Caching

Large datasets (e.g., LAU or high-resolution files) can exceed 50MB. Use:

gisco_set_cache_dir("./path/to/location")

Files will be stored locally for faster access.

Contribute

Check the GitHub page forsource code.

Contributions are welcome:

Citation

To cite ‘giscoR’ in publications use:

Hernangómez D (2025).giscoR: Download Map Data from GISCO API - Eurostat.doi:10.32614/CRAN.package.giscoRhttps://doi.org/10.32614/CRAN.package.giscoR,https://ropengov.github.io/giscoR/.

A BibTeX entry for LaTeX users is

@Manual{R-giscoR,  title= {{giscoR}: Download Map Data from GISCO API- Eurostat},  doi= {10.32614/CRAN.package.giscoR},  author= {Diego Hernangómez},  year= {2025},  version= {1.0.0},  url= {https://ropengov.github.io/giscoR/},  abstract= {Tools to download data from theGISCO (Geographic Information System of the Commission) Eurostat database<https://ec.europa.eu/eurostat/web/gisco>. Global and European map data available. This package isin no way officially related to or endorsed by Eurostat.},}

General copyright

Eurostat’s general copyright notice and licence policy applies. Moreover, there are specific rules that apply to some of the following datasets available for downloading. The download and use of these data are subject to these rules being accepted. See ouradministrative units andstatistical units for more details.

Source:https://ec.europa.eu/eurostat/web/gisco/geodata

Disclaimer

This package is neither affiliated with nor endorsed by Eurostat. The authors are not responsible for any misuse of the data.

Links

License

Community

Citation

Developers


[8]ページ先頭

©2009-2025 Movatter.jp