{"id":31556985,"url":"https://github.com/artod83/netmap","last_synced_at":"2025-10-04T23:20:58.871Z","repository":{"id":56930794,"uuid":"440847703","full_name":"artod83/netmap","owner":"artod83","description":"Represent Network Objects on a Map","archived":false,"fork":false,"pushed_at":"2024-02-26T13:21:50.000Z","size":715,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-28T01:42:56.537Z","etag":null,"topics":["ggplot2","network-analysis","r","sfc"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artod83.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-22T12:17:12.000Z","updated_at":"2025-03-22T10:40:18.000Z","dependencies_parsed_at":"2022-08-21T00:01:13.446Z","dependency_job_id":null,"html_url":"https://github.com/artod83/netmap","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/artod83/netmap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artod83%2Fnetmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artod83%2Fnetmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artod83%2Fnetmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artod83%2Fnetmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artod83","download_url":"https://codeload.github.com/artod83/netmap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artod83%2Fnetmap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278386651,"owners_count":25978217,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ggplot2","network-analysis","r","sfc"],"created_at":"2025-10-04T23:20:57.384Z","updated_at":"2025-10-04T23:20:58.865Z","avatar_url":"https://github.com/artod83.png","language":"R","funding_links":[],"categories":[],"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/\",\n  out.width = \"100%\"\n)\n```\n\n# netmap\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\nNetmap is a package that aids in the visualizations of network objects (made with the `network` or the `igraph` package) on geographical maps, imported through `sf`. Vertices in the network are linked with features in the `sf` object either directly if they share a common attribute or by an optional look-up table.\nThe package either creates data frames that can be used in a `ggplot2` plot or adds to `sf` features attributes like centrality indices or variables representing connections to a certain node.\n\n## Installation\n\nYou can install the development version of netmap from [GitHub](https://github.com/) with:\n\n``` {r eval=FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"artod83/netmap\")\n```\n\n## Example\n\nWe take a network object, where each vertex is a geographical object, and overlay the network on the map. I.e. a network could represent direct bus routes between cities. \nWe can plot the network as overlayed on the complete map or just the 4 cities in the network\nThe Friuli Venezia Giulia region in northeastern Italy has four major cities: from east to west, Trieste, Gorizia, Udine and Pordenone. Let's imagine that we want to plot a network with these cities as vertices and edges between Trieste and Gorizia, Gorizia and Udine, Trieste and Udine and Udine and Pordenone.\n\n```{r network_overlay, eval=FALSE}\nlibrary(ggplot2)\nlibrary(netmap)\ndata(fvgmap)\nroutes=network::network(matrix(c(0, 1, 1, 0, \n                                 1, 0, 1, 0, \n                                 1, 1, 0, 1, \n                                 0, 0, 1, 0), nrow=4, byrow=TRUE))\nnetwork::set.vertex.attribute(routes, \"names\", value=c(\"Trieste\", \"Gorizia\", \"Udine\", \"Pordenone\"))\nroutes_df=netmap::ggnetmap(routes, fvgmap, m_name=\"Comune\", n_name=\"names\")\nggplot() +\n  geom_sf(data=fvgmap) +\n  ggnetwork::geom_edges(data=routes_df, aes(x=x,y=y, xend=xend, yend=yend), colour=\"red\") +\n  ggnetwork::geom_nodes(data=routes_df, aes(x=x,y=y)) +\n  ggnetwork::geom_nodetext(data=routes_df, aes(x=x,y=y, label = Comune), fontface = \"bold\") +\n  theme_blank()\n```\n```{r plot_1, echo=FALSE, eval=TRUE}\nknitr::include_graphics('man/figures/netmap-1.png')\n```\n\nIt is also possible to plot a sf object with centrality measures of the network:\n\n```{r centrality, eval=FALSE}\nroutes2=network::network(matrix(c(0, 1, 1, 0, 0, 1 ,\n                                 1, 0, 1, 0, 0, 1,\n                                 1, 1, 0, 1, 1, 1,\n                                 0, 0, 1, 0, 1, 1,\n                                 0, 0, 1, 1, 0, 0,\n                                 1, 1, 1, 1, 0, 0), nrow=6, byrow=TRUE))\nnetwork::set.vertex.attribute(routes2, \"names\", \n                              value=c(\"Trieste\", \"Gorizia\", \"Udine\", \"Pordenone\", \n                                      \"Tolmezzo\", \"Grado\"))\nlkpt=data.frame(Pro_com=c(32006, 31007, 30129, 93033, 30121, 31009), \n                names=c(\"Trieste\", \"Gorizia\", \"Udine\", \"Pordenone\", \"Tolmezzo\", \n                        \"Grado\"))\nroutes2_df=netmap::ggnetmap(routes2, fvgmap, lkpt, m_name=\"Pro_com\", n_name=\"names\")\nmap_centrality=netmap::ggcentrality(routes2, fvgmap, lkpt, m_name=\"Pro_com\", \n                                    n_name=\"names\", par.deg=list(gmode=\"graph\"))\nggplot() +\n  geom_sf(data=fvgmap) +\n  geom_sf(data=map_centrality, aes(fill=degree)) +\n  ggnetwork::geom_edges(data=routes2_df, aes(x=x,y=y, xend=xend, yend=yend), colour=\"red\") +\n  ggnetwork::geom_nodes(data=routes2_df, aes(x=x,y=y)) +\n  ggnetwork::geom_nodetext(data=routes2_df, aes(x=x,y=y, label = names), fontface = \"bold\", colour=\"\") +\n  theme_blank()\n```\n\n```{r plot_2, echo=FALSE, eval=TRUE}\nknitr::include_graphics('man/figures/netmap-2.png')\n```\n\nJust the network can be plotted as well without using `ggplot2`. For this purpose, \na simple layout function, `network.layout.extract_coordinates`, is provided for use with `plot.network` or `plot.igraph`. A user-friendly wrapper, `netmap_plot`, is available.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartod83%2Fnetmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartod83%2Fnetmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartod83%2Fnetmap/lists"}