{"id":13857832,"url":"https://github.com/riatelab/tanaka","last_synced_at":"2025-08-08T13:25:35.617Z","repository":{"id":41285876,"uuid":"173094032","full_name":"riatelab/tanaka","owner":"riatelab","description":"Tanaka Maps with R","archived":false,"fork":false,"pushed_at":"2023-11-28T15:43:16.000Z","size":13482,"stargazers_count":79,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-05T04:13:33.268Z","etag":null,"topics":["map","r-package","spatial","tanaka"],"latest_commit_sha":null,"homepage":"https://rgeomatic.hypotheses.org/1758","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.md","changelog":null,"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}},"created_at":"2019-02-28T10:46:03.000Z","updated_at":"2025-01-14T04:47:20.000Z","dependencies_parsed_at":"2023-11-28T17:09:53.892Z","dependency_job_id":null,"html_url":"https://github.com/riatelab/tanaka","commit_stats":{"total_commits":56,"total_committers":3,"mean_commits":"18.666666666666668","dds":0.1964285714285714,"last_synced_commit":"b42628286b8fbf9f494400a969862857c07fabf7"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Ftanaka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Ftanaka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Ftanaka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Ftanaka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riatelab","download_url":"https://codeload.github.com/riatelab/tanaka/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244047631,"owners_count":20389206,"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-package","spatial","tanaka"],"created_at":"2024-08-05T03:01:48.279Z","updated_at":"2025-03-17T14:09:29.933Z","avatar_url":"https://github.com/riatelab.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"\n\n# Tanaka \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"140\"/\u003e\n\n[![Cran version](https://www.r-pkg.org/badges/version-ago/tanaka)](https://CRAN.R-project.org/package=tanaka)\n[![R-CMD-check](https://github.com/riatelab/tanaka/workflows/R-CMD-check/badge.svg)](https://github.com/riatelab/tanaka/actions)\n[![Coverage status](https://codecov.io/gh/riatelab/tanaka/branch/master/graph/badge.svg)](https://app.codecov.io/github/riatelab/tanaka?branch=master)\n![N. Download](https://cranlogs.r-pkg.org/badges/grand-total/tanaka?color=brightgreen)  \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\n\n\nAlso called \"relief contours method\", \"illuminated contour method\" or \"shaded \ncontour lines method\", the Tanaka method\u003csup\u003e[1](#fn1)\u003c/sup\u003e enhances the representation of topography \non a map by using shaded contour lines. The result is a 3D-like map.\n\nThis package is a simplified implementation of the Tanaka method, north-west white contours represent \nilluminated topography and south-east black contours represent shaded topography. \nEven if the results are quite satisfactory, a more refined method could be used \nbased on the Kennelly and Kimerling's paper\u003csup\u003e[2](#fn2)\u003c/sup\u003e. \n\n\n`tanaka` is a small package with two functions:\n\n- `tanaka()` uses a `terra` object and displays the map directly;\n- `tanaka_contour()` builds the isopleth polygon layer. \n\n\nThe contour lines creation relies on [`mapiso`](https://github.com/riatelab/mapiso), \nspatial manipulation and display rely on [`sf`](https://github.com/r-spatial/sf). \n\n\n## Installation\n* From CRAN\n```r\ninstall.packages(\"tanaka\")\n```\n\n* Development version on GitHub\n```r\nrequire(remotes)\ninstall_github(\"riatelab/tanaka\")\n```\n\n## Demo\n\n* This example is based on the dataset shipped within the package. \n```r\nlibrary(tanaka)\nlibrary(terra)\nras \u003c- rast(system.file(\"tif/elev.tif\", package = \"tanaka\"))\ntanaka(ras, breaks = seq(80,400,20), \n       legend.pos = \"topright\", legend.title = \"Elevation\\n(meters)\")\n```\n![](https://raw.githubusercontent.com/riatelab/tanaka/master/img/ex1.png)  \n\n* This example is based on an  elevation raster downloaded via \n[`elevatr`](https://github.com/jhollist/elevatr). \n```r\nlibrary(tanaka)\nlibrary(elevatr)\nlibrary(terra)\n# use elevatr to get elevation data\nras \u003c- get_elev_raster(locations = data.frame(x = c(6.7, 7), y = c(45.8,46)),\n                       z = 10, prj = \"EPSG:4326\", clip = \"locations\")\nras \u003c- rast(ras)\n# custom color palette\ncols \u003c- c(\"#F7E1C6\", \"#EED4C1\", \"#E5C9BE\", \"#DCBEBA\", \"#D3B3B6\", \"#CAA8B3\", \n          \"#C19CAF\", \"#B790AB\", \"#AC81A7\", \"#A073A1\", \"#95639D\", \"#885497\", \n          \"#7C4692\", \"#6B3D86\", \"#573775\", \"#433266\", \"#2F2C56\", \"#1B2847\")\n# display the map\ntanaka(ras, breaks = seq(500,4800,250), col = cols)\n```\n![](https://raw.githubusercontent.com/riatelab/tanaka/master/img/ex2.png)  \n\n* The last example illustrates the use of tanaka with non-topographical data. \nThis map is based on the [Global Human Settlement Population Grid](https://ghsl.jrc.ec.europa.eu/ghs_pop.php) (1km). \n\n```r\nlibrary(terra)\nlibrary(sf)\nlibrary(tanaka)\nlibrary(mapsf)\n# Download\ntempzip \u003c- tempfile()\ntempfolder \u003c- tempdir()\ndata_url \u003c- paste0(\"http://cidportal.jrc.ec.europa.eu/ftp/jrc-opendata/GHSL/\", \n                   \"GHS_POP_GPW4_GLOBE_R2015A/GHS_POP_GPW42015_GLOBE_R2015A_54009_1k/\", \n                   \"V1-0/GHS_POP_GPW42015_GLOBE_R2015A_54009_1k_v1_0.zip\")\ndownload.file(data_url, tempzip)\nunzip(tempzip, exdir = tempfolder)\n# Import\npop2015 \u003c- rast(paste0(tempfolder, \n                       \"/GHS_POP_GPW42015_GLOBE_R2015A_54009_1k_v1_0/\",\n                       \"GHS_POP_GPW42015_GLOBE_R2015A_54009_1k_v1_0.tif\"))\n# Mask raster\ncenter \u003c- st_as_sf(data.frame(x=425483.8, y=5608290), \n                   coords=(c(\"x\",\"y\")), \n                   crs = st_crs(pop2015))\ncenter \u003c- st_buffer(center, dist = 800000)\nras \u003c- crop(pop2015, st_bbox(center)[c(1,3,2,4)])\n# Smooth values\nmat \u003c- focalMat(x = ras, d = c(10000), type = \"Gauss\")\nrassmooth \u003c- focal(x = ras, w = mat, fun = sum, na.rm = TRUE)\n# Map\nbks \u003c- c(0,25,50,100,250,500,750,1000,1750,2500,5000, 7500,10000)\nmf_export(x = center, filename = \"circle.png\", width = 800, res = 100)\ntanaka(x = rassmooth,\n       breaks = bks,\n       mask = center,\n       col = hcl.colors(n = 12, palette = \"Inferno\"),\n       shift = 2500,\n       add = TRUE,\n       legend.pos = \"topleft\",\n       legend.title = \"Inhabitants\\nper km2\")\nmf_map(center, add = TRUE, border = \"white\", col = NA, lwd = 6)\nmf_title(txt = \"Smoothed Population Density\")\nmf_credits(paste0(\"T. Giraud, 2022\\n\",\n                  \"Data : European Commission, Joint Research Centre (JRC); \", \n                  \"Columbia University, CIESIN (2015): GHS population grid, \", \n                  \"derived from GPW4.\"))\ntext(-250000 ,6420000, \"Gaussian filter, sigma = 10km\", \n     adj = 0, font = 3, cex = .8, xpd = TRUE )\ndev.off()\n```\n\n\n![](https://raw.githubusercontent.com/riatelab/tanaka/master/img/circle.png)\n\n## Alternative Package\nThe [`metR` package](https://CRAN.R-project.org/package=metR) allows to draw [Tanaka contours with ggplot2](https://eliocamp.github.io/metR/reference/geom_contour_tanaka.html).\n\n\n-------------------------------------------\n\n\u003ca name=\"fn1\"\u003e1\u003c/a\u003e: Tanaka, K. (1950). The relief contour method of representing topography on maps. *Geographical Review, 40*(3), 444-456.  \n\u003ca name=\"fn2\"\u003e2\u003c/a\u003e: Kennelly, P., \u0026 Kimerling, A. J. (2001). Modifications of Tanaka's illuminated contour method. *Cartography and Geographic Information Science, 28*(2), 111-123.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friatelab%2Ftanaka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friatelab%2Ftanaka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friatelab%2Ftanaka/lists"}