{"id":14068864,"url":"https://github.com/mdsumner/wmts","last_synced_at":"2025-08-10T08:33:21.524Z","repository":{"id":72212079,"uuid":"220982958","full_name":"mdsumner/wmts","owner":"mdsumner","description":"PLEASE IGNORE, use hypertidy/gdalio instead ","archived":false,"fork":false,"pushed_at":"2021-07-21T03:57:46.000Z","size":4141,"stargazers_count":4,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T12:16:24.325Z","etag":null,"topics":[],"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/mdsumner.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-11T13:04:12.000Z","updated_at":"2022-02-22T02:36:24.000Z","dependencies_parsed_at":"2023-04-22T12:24:21.626Z","dependency_job_id":null,"html_url":"https://github.com/mdsumner/wmts","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fwmts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fwmts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fwmts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fwmts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdsumner","download_url":"https://codeload.github.com/mdsumner/wmts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239587244,"owners_count":19663892,"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":[],"created_at":"2024-08-13T07:06:27.112Z","updated_at":"2025-02-19T02:48:04.590Z","avatar_url":"https://github.com/mdsumner.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\neditor_options: \n  chunk_output_type: console\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  eval = TRUE,\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# wmts\n\n\u003c!-- badges: start --\u003e\n[![Travis build status](https://travis-ci.org/mdsumner/wmts.svg?branch=master)](https://travis-ci.org/mdsumner/wmts)\n\u003c!-- badges: end --\u003e\n\nThe goal of wmts is to obtain imagery from online image servers. You can provide *any URL* with a `GetCapabilities.xml` and quickly get an image for any region at any resolution. \n\n*Any URL*? Only Pseudo Mercator services tested so far, see examples below for success stories.  Please [file an issue](https://github.com/mdsumner/wmts/issues) or ping me [on twitter](https://twitter.com/mdsumner) if you have wants/needs/suggestions/bug-fixes/high-fives.\n\n\n## The wmts() function\n\nUse `loc` to specify a location (`cbind(lon, lat)`) and `buffer` to give a radius around that point in metres. Alternatively, any spatial object can be used as `loc` and its extent (in the Mercator tile server projection) will be used. \n\nThere is an argument `max_tiles` which is 9 by default (3x3 256x256 tiles) and ensures a reasonably small sized result. Increase max_tiles to obtain greater resolution (squares make sense, i.e. 16, 25, 36, 49, ... but the actual shape depends on `loc` and `buffer`). \n\nThe `zoom` argument can be used but please take care, the function will report the zoom in use and it's advisable not to increase this much (use max_tiles to get a known maximum amount of data). \n\nSee [GDAL WMTS documentation](https://gdal.org/drivers/raster/wmts.html)  for *technical details* on this GDAL-based approach.\n\n\n## Beware\n\n* will create temporary files (gdalwmscache, and raster temp)\n* no checks for in-bounds for tiles\n* no safety checks if you manually set a large zoom\n* no idea what systems/OS this works on yet (tested on Ubuntu)\n\n## TODO\n\n- [x] need to deal with various inputs \n- [x] fix URL forms (http/s vs WMTS:)\n- [ ] add providers\n\n## Example\n\n```{r example}\n## remotes::install_github(\"mdsumner/wmts\")\ncentre \u003c- c(-80.888, 32.332)  ## lonlat\nradius \u003c- 4000                ## metres\nu \u003c- \"WMTS:https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/WMTS/1.0.0/WMTSCapabilities.xml,layer=USGSTopo,tilematrixset=default028mm\"\nlibrary(wmts)\n\n## note that input can be centre (longlat pt), buffer (km) or a spatial object (ignore buffer)\n## output is a raster in World Mercator\nx \u003c- wmts(u, centre, buffer = radius) ## zoom determined interactively, don't use a hardcoded zoom\nraster::plotRGB(x, interpolate = TRUE)\n#f \u003c- system.file(\"gpkg/nc.gpkg\", package = \"sf\", mustWork = TRUE)\n#sf \u003c- sf::read_sf(f)\n#x \u003c- wmts(u, sf)\ntab \u003c- tibble::as_tibble(raster::as.data.frame(x, xy = TRUE))\nnames(tab) \u003c- c(\"x\", \"y\", \"red\", \"green\", \"blue\")\n##tab \u003c- dplyr::filter(tab, !is.na(red))  ##... when we have missing values, we should drop them or rgb() will error\ntab$hex \u003c- rgb(tab$red, tab$green, tab$blue, maxColorValue = 255)\nlibrary(ggplot2)\nggplot(tab, aes(x, y, fill = hex)) +\n  geom_raster(interpolate = TRUE) +\n  coord_equal() +\n  scale_fill_identity()\n```\n\n\n## Tasmania!\n\nGet a Tassie example. \n\n```{r tassie}\next \u003c- raster::extent(146, 148, -43, -40.5)\nu \u003c- \"WMTS:https://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/Topographic/MapServer/WMTS/1.0.0/WMTSCapabilities.xml,layer=Basemaps_Topographic,tilematrixset=default028mm\"\n\nimg \u003c- wmts(u, loc = ext)\nraster::plotRGB(img, interpolate = TRUE)\n\northo \u003c- wmts(\"https://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/Orthophoto/MapServer/WMTS/1.0.0/WMTSCapabilities.xml\", raster::extent(147.125, 147.528, -43.054, -42.717), max_tiles = 16)\nraster::plotRGB(ortho, interpolate = TRUE)\n\n\n## note that we can use an spatial object for the extent, saving much pain\nurl_shade \u003c- \"https://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/HillshadeGrey/MapServer/WMTS/1.0.0/WMTSCapabilities.xml\"\ngreyshade \u003c- wmts(url_shade, ortho)\nraster::plotRGB(greyshade, interpolate = TRUE)\n\nprefix_shade \u003c- \"WMTS:https://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/HillshadeGrey/MapServer/WMTS/1.0.0/WMTSCapabilities.xml\"\nshade \u003c- wmts(prefix_shade, ortho)\n# same: raster::plotRGB(shade, interpolate = TRUE)\n\nprefix_shade \u003c- \"WMTS:https://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/Hillshade/MapServer/WMTS/1.0.0/WMTSCapabilities.xml\"\nhillshade \u003c- wmts(prefix_shade, ortho)\nraster::plotRGB(hillshade)\n\nzlocal \u003c- raster::raster(raster::extent(c(16391003, 16394978, -5301061, -5298768)), crs = raster::projection(ortho))\nzz \u003c- wmts(prefix_shade, zlocal)\nraster::plotRGB(zz)\n\nTasmapRaster \u003c- \"https://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/TasmapRaster/MapServer/WMTS/1.0.0/WMTSCapabilities.xml\"\nxx \u003c- wmts(TasmapRaster, zlocal, max_tiles = 16)\nraster::plotRGB(xx)\n\n\nstreet \u003c- \"https://services.thelist.tas.gov.au/arcgis/rest/services/Raster/TTSA/MapServer/WMTS/1.0.0/WMTSCapabilities.xml\"\nst \u003c- wmts(street, raster::shift(zlocal, 5000, 5000), max_tiles = 36)\nraster::plotRGB(st, interpolate = TRUE)\n\n```\n\nA list of Tasmanian servers is here: https://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps\n\n\n\n## Earthdata\n\nYou want the REST GetCapabilities(.xml), and we have to prefix with \"WMTS:\" *and include* the layer name (WIP).\n\nhttps://wiki.earthdata.nasa.gov/display/GIBS/GIBS+API+for+Developers#GIBSAPIforDevelopers-ServiceEndpointsandGetCapabilities\n\n\n```{r earthdata}\nu \u003c- \"WMTS:https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/1.0.0/WMTSCapabilities.xml,layer=MODIS_Terra_L3_Land_Surface_Temp_Monthly_Day\"\nim \u003c- wmts(u, cbind(0, 0), 20037508, zoom = 0)\nlibrary(raster)\nplotRGB(im, interpolate = TRUE)\n\nim2 \u003c- wmts(u, extent(100, 180, -55, 15), max_tiles= 36)\n\nplotRGB(im2, interpolate = TRUE)\n\n\n```\n--- \n\nPlease note that the wmts project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/1/0/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2Fwmts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdsumner%2Fwmts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2Fwmts/lists"}