{"id":18722676,"url":"https://github.com/mdsumner/cartogony","last_synced_at":"2025-11-11T05:30:23.057Z","repository":{"id":72211223,"uuid":"65666863","full_name":"mdsumner/cartogony","owner":"mdsumner","description":"globes and maps in R","archived":false,"fork":false,"pushed_at":"2017-02-04T13:43:10.000Z","size":23890,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T12:17:23.321Z","etag":null,"topics":["cartography","gis","maps","rstats","spatial-data"],"latest_commit_sha":null,"homepage":null,"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":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-08-14T13:11:25.000Z","updated_at":"2022-01-31T12:07:02.000Z","dependencies_parsed_at":"2023-02-24T05:30:24.846Z","dependency_job_id":null,"html_url":"https://github.com/mdsumner/cartogony","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"15be3771d1e8b9f38db59cee90225868f3a7459f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fcartogony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fcartogony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fcartogony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fcartogony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdsumner","download_url":"https://codeload.github.com/mdsumner/cartogony/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":["cartography","gis","maps","rstats","spatial-data"],"created_at":"2024-11-07T13:42:24.668Z","updated_at":"2025-11-11T05:30:23.008Z","avatar_url":"https://github.com/mdsumner.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\n## Globey globes in R\n\nThese are hard to do for several reasons: \n\n* topology is not present in most map data and tools for them\n* 'sp::spTransform' will not return a result with missing coordinates\n* 'rgdal::project' only works on raw coordinates\n* individual plot frames take time, so need to be cached (or the preparation cached)\n\nThis readme shows a couple of ways to get around all but the topology problems, and may in time become a way to explore solutions for the topology as well. I think the best way will be to use RTriangle, which has the bonus that that's also the way to plot stuff in 3D. \n\n\nFor the animation I used the approach in the 'gganimate' package README. NOTE: as well as ImageMagick for a standalone GIF, you need **named chunks** in the RMarkdown for this to work. \n\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README/README-fig-\",\n  cache.path = \"README/README-cache-\"\n)\n\nlibrary(animation)\nlibrary(knitr)\nani.options(autobrowse = FALSE, interval = 0.2)\n\nopts_knit$set(animation.fun = function(x, options, format = \"gif\") {\n  x = c(knitr:::sans_ext(x), knitr:::file_ext(x))\n  fig.num = options$fig.num\n  format = sub(\"^[.]\", \"\", format)\n  fig.fname = paste0(sub(paste0(fig.num, \"$\"), \"*\", x[1]), \n                     \".\", x[2])\n  mov.fname = paste0(sub(paste0(fig.num, \"$\"), \"\", x[1]), \".\", \n                     format)\n\n  # order correctly\n  figs \u003c- Sys.glob(fig.fname)\n  figs \u003c- figs[order(as.numeric(stringr::str_match(figs, paste0(\"(\\\\d+)\\\\.\", x[2]))[, 2]))]\n\n  animation::im.convert(figs, output = mov.fname)\n  \n  sprintf(\"![%s](%s)\", options$label, paste0(opts_knit$get(\"base.url\"), mov.fname))\n})\n\nopts_chunk$set(cache = TRUE, message = FALSE, warning = FALSE, fig.show = \"animate\")\n```\n\n```{r prep}\n## to snapshot the frame loop\nlibrary(animation)\n## for PROJ4\nlibrary(rgdal)  \n## for a simple world coastline\nlibrary(maptools) \n## for longlat lines \nlibrary(graticule) \n ## for working with spatial in a  generic way\nlibrary(spbabel) \n## for functions to project coordinates in a data frame version of Spatial\nlibrary(cartogony)  \nlibrary(rworldmap)\ndata(countriesLow)\nwrldtab \u003c- sptable(countriesLow)\n\ngrat0 \u003c- sptable(graticule())\n```\n\n\n\n```{r anim}\nrotseq \u003c- head(seq(-180, 180, length = 36), -1L)\nlat \u003c- -42\nfor (i in seq_along(rotseq)) {\ngrat \u003c- projDFcolumns(grat0 , prjmaker(rotseq[i], lat))\np \u003c- par(mar = rep(0, 4))\nplot(grat$X, grat$Y, pch = \".\", asp = 1, axes = FALSE, xlab = \"\", ylab = \"\")\nlapply(split(grat, grat$branch_), function(x) lines(x$X, x$Y))\n\n\nwrld0 \u003c- projDFcolumns(wrldtab, prjmaker(rotseq[i], lat))\njunk \u003c- lapply(split(wrld0, wrld0$branch_), function(x) try(polygon(x$X, x$Y, col = \"grey\"), silent = TRUE))\n\npar(p)\n\n}\n\n\n```\n\n\n\n\n```{r anim2}\nrotseq \u003c- head(seq(-180, 180, length = 36), -1L)\nlat \u003c- 42\nfor (i in seq_along(rotseq)) {\ngrat \u003c- projDFcolumns(grat0, prjmaker(rotseq[i], lat))\np \u003c- par(mar = rep(0, 4))\nplot(grat$X, grat$Y, pch = \".\", asp = 1, axes = FALSE, xlab = \"\", ylab = \"\")\nlapply(split(grat, grat$branch_), function(x) lines(x$X, x$Y))\n\n\nwrld0 \u003c- projDFcolumns(wrldtab, prjmaker(rotseq[i], lat))\njunk \u003c- lapply(split(wrld0, wrld0$branch_), function(x) try(polygon(x$X, x$Y, col = \"grey\"), silent = TRUE))\n\npar(p)\n\n}\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2Fcartogony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdsumner%2Fcartogony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2Fcartogony/lists"}