{"id":13857420,"url":"https://github.com/riatelab/maptiles","last_synced_at":"2025-05-16T18:05:55.447Z","repository":{"id":46805732,"uuid":"307737385","full_name":"riatelab/maptiles","owner":"riatelab","description":"Download, compose and display map tiles with R","archived":false,"fork":false,"pushed_at":"2025-01-30T09:24:17.000Z","size":24553,"stargazers_count":109,"open_issues_count":0,"forks_count":11,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-10T16:25:24.296Z","etag":null,"topics":["map","r","rspatial","tiles"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/riatelab.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null}},"created_at":"2020-10-27T15:03:44.000Z","updated_at":"2025-03-29T04:37:44.000Z","dependencies_parsed_at":"2023-12-08T10:37:27.137Z","dependency_job_id":"fe53d955-1f28-49ef-943a-b36aa0b794e4","html_url":"https://github.com/riatelab/maptiles","commit_stats":{"total_commits":139,"total_committers":8,"mean_commits":17.375,"dds":"0.15827338129496404","last_synced_commit":"513b7d4ee97bf193e2470044609af2624425792e"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Fmaptiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Fmaptiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Fmaptiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Fmaptiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riatelab","download_url":"https://codeload.github.com/riatelab/maptiles/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248601062,"owners_count":21131607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["map","r","rspatial","tiles"],"created_at":"2024-08-05T03:01:36.479Z","updated_at":"2025-04-12T16:47:57.156Z","avatar_url":"https://github.com/riatelab.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\nknitr::knit_hooks$set(margin = function(before, options, envir) {\n  if (before) {\n    par(mar = c(0, 0, 0, 0))\n  }\n})\n```\n\n# maptiles \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"140\"/\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/riatelab/maptiles/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/riatelab/maptiles/actions/workflows/check-standard.yaml)\n[![Codecov test coverage](https://codecov.io/gh/riatelab/maptiles/branch/main/graph/badge.svg)](https://app.codecov.io/gh/riatelab/maptiles?branch=main)\n[![CRAN status](https://www.r-pkg.org/badges/version/maptiles)](https://CRAN.R-project.org/package=maptiles)\n![](https://cranlogs.r-pkg.org/badges/maptiles)\n[![Project Status: Active – The project has reached a stable, usable\nstate and is being actively\ndeveloped.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n\u003c!-- badges: end --\u003e\n\nTo create maps from tiles, `maptiles` downloads, composes and displays tiles \nfrom a large number of providers (e.g. OpenStreetMap, Stadia, Esri, CARTO, or \nThunderforest). \n\n## Installation\n\nYou can install the released version of `maptiles` from [CRAN](https://CRAN.R-project.org/package=maptiles) with:\n\n``` r\ninstall.packages(\"maptiles\")\n```\n\nYou can install the development version of `maptiles` from GitHub with:\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"riatelab/maptiles\")\n```\n\n## Demo\n\nThis is a basic example which shows you how to dowload and display OpenStreetMap \ntiles over North Carolina:\n\n\n```{r example, fig.ext=\"png\", margin = TRUE, fig.width=808/96, fig.height = 303/96, dpi = 96, fig.show='hide'}\nlibrary(sf)\nlibrary(maptiles)\n# import North Carolina counties\nnc_raw \u003c- st_read(system.file(\"shape/nc.shp\", package = \"sf\"), quiet = TRUE)\n# Project to EPSG:3857\nnc \u003c- st_transform(nc_raw, \"EPSG:3857\")\n# dowload tiles and compose raster (SpatRaster)\nnc_osm \u003c- get_tiles(nc, crop = TRUE)\n# display map\nplot_tiles(nc_osm)\n# add Norh Carolina counties\nplot(st_geometry(nc), col = NA, add = TRUE)\n# add credit\nmtext(text = get_credit(\"OpenStreetMap\"), side = 1, line = -1, adj = .99)\n```\n\n![](man/figures/README-example-1.png)\n\n\n`maptiles` gives access to a lot of tiles servers, but it is possible to \nadd others. The following example demonstrates the setting of a map tiles server\nand how to cache the original tiles for future use:\n\n\n```{r example2,fig.ext=\"png\", margin = TRUE, fig.width=1615/96, fig.height = 605/96, fig.show='hide', dpi = 96}\n# define the tile server parameters\nosmpos \u003c- create_provider(\n  name = \"CARTO.POSITRON\",\n  url = \"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png\",\n  sub = c(\"a\", \"b\", \"c\", \"d\"),\n  citation = \"© OpenStreetMap contributors © CARTO \"\n)\n# dowload tiles and compose raster (SpatRaster)\nnc_osmpos \u003c- get_tiles(\n  x = nc, provider = osmpos, crop = TRUE,\n  cachedir = tempdir(), verbose = TRUE, retina = TRUE\n)\n# display map\nplot_tiles(nc_osmpos)\n# display credits\nmtext(text = get_credit(osmpos), side = 1, line = -1, adj = .99)\n```\n\n![](man/figures/README-example2-1.png)\n\nThe following figure shows mini maps for most of the tiles providers available:\n\n![](man/figures/README-front.png)\n\n\n## Projection\n\nOriginal tiles use a projection known as \"Web Mercator\", \n\"WGS84 / Pseudo Mercator\", \"Google Mercator\", \"EPSG:3857\" or \"EPSG:900913\". \nIn most cases `get_tiles()` uses the projection of its `x` argument to \nreproject the tiles. If you wish to avoid any deformation induced by the \nreprojection process, use \"EPSG:3857\" for `x` projection.\n\n## Attribution of map tiles\n\nAll maps available through `maptiles` are offered freely by various providers. \nThe only counterpart from the user is to properly display an attribution text \non the maps. \n`get_credit()` displays a short attribution text to add on each map \nusing the downloaded tiles. \n\n## Alternatives\n\nThere are many alternative packages that pursue the same objective as \n`maptiles`. Some focus on a specific map tiles provider (e.g. Mapbox, Google, \nOpenStreetMap) or on a specific graphics device (`ggplot2`). The goal of `maptiles` \nis to be flexible enough to allow the use of different providers and to have a \nminimal number of robust and modern dependencies.\nHowever, depending on the use case, one of following packages may better \nsuit your needs:  \n\n* [`ceramic`](https://github.com/hypertidy/ceramic)  \n* [`ggmap`](https://github.com/dkahle/ggmap) (`ggplot2` focused)\n* [`ggspatial`](https://github.com/paleolimbot/ggspatial) (`ggplot2` focused, based on `rosm`)\n* [`mapboxapi`](https://github.com/walkerke/mapboxapi) (mapbox)\n* [`mapsapi`](https://github.com/michaeldorman/mapsapi/) (google, based on `RgoogleMaps`)\n* [`OpenStreetMap`](https://github.com/ifellows/ROSM) (requires Java)\n* [`RgoogleMaps`](https://github.com/markusloecher/rgooglemaps) (google)\n* [`rosm`](https://github.com/paleolimbot/rosm)\n* ...\n\n## Note\n\nNot to be confused with [`tilemaps`](https://github.com/kaerosen/tilemaps), that \"implements an algorithm for generating maps, known as tile maps, in which each region is represented by a single tile of the same shape and size.\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friatelab%2Fmaptiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friatelab%2Fmaptiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friatelab%2Fmaptiles/lists"}