Assign Latitude and Longitude to Edges

Dear RStudio Community!

I am currently writing a paper on the international flows of migration and remittances for university. I am conducting a network analysis and have received some interesting results. I would like to visualize some edges/flows of migration/remittances on a world map, but I do not know how.

I extracted the edges I would like to visualize to a data.frame with the following columns: From, To, Weight
For example: (From) Afghanistan, (To) Pakistan, (Weight) XXXX

I assume that I would have to add the corresponding longitude and latitude to the rows through a conditional order. I have already obtained the country centroids from Harvard WorldMap. How do I add them to the countries to show them on the world map? Is that possible? In addition, some countries are named a bit differently, like Congo (rep./Republic of et cetera).

I am new to the world of R and Network Analysis. I come from Germany, so I apologise for my English language skills. I am looking forward to your advise!

Best Regards

The {sf} package provides an approach. It provides the spatial geometry as a variable in a data frame than can be joined by applicable country codes with data frames such as this one.

Labeling and positioning according to centroid (which is calculated without having to be specified externally) can be placed on a second layer.

The edge repre

There sf_geom methods to carry out the project in layers.

  1. Project mutlipolygons representing country outlines according to a Mercator (or preferably less biased) projection of the geoid

  2. Prepare the 197^2 matrix of node/weights (representing the possible edge) as a column of countries to match the rows of countries. The diagonal, of course, will be zero.

  3. Decide on whether to project the edges as straight lines or great circles, and extract line geometries from the corresponding pairs of geometry objects in the combined data frame.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.