Last active
January 24, 2022 11:14
-
-
Save rCarto/0c735ccbe09884fb8ee6bac7e457cac8 to your computer and use it in GitHub Desktop.
Revisions
-
rCarto revised this gist
Jan 21, 2022 . No changes.There are no files selected for viewing
-
rCarto created this gist
Jan 21, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ library(rnaturalearth) library(mapsf) library(fisheye) ct <- ne_download(scale = 50, returnclass = "sf") oc <- ne_download(type = "ocean", category = "physical", scale = 50, returnclass = "sf") x <- st_transform(ct, "+proj=natearth2") z <- st_transform(oc, "+proj=natearth2") mf_export(z, "initial.png", theme = "green") mf_map(z, col = "white", border ="white", add = T) mf_map(x, col = "lightblue", border = "white", lwd = .7, add = T) mf_map(x, "POP_EST", "prop", border = "grey80", inches = .3, leg_title = "Population", leg_frame = T) mf_title("Original Map") dev.off() xCHN <- fisheye(x = x, centre = x[x$ADM0_A3 %in% "CHN",], k = 6) zCHN <- fisheye(x = z, centre = x[x$ADM0_A3 %in% "CHN",], k = 6) mf_export(zCHN, "china.png", theme = "green") mf_map(zCHN, col = "white", border ="white", add = T) mf_map(xCHN, col = "lightblue", border = "white", lwd = .7, add = T) mf_map(xCHN, "POP_EST", "prop", border = "grey80", inches = .3, leg_title = "Population", leg_frame = T) mf_title("Transformed map, center = China") dev.off() xNGA <- fisheye(x = x, centre = x[x$ADM0_A3 %in% "NGA",], k = 6) zNGA <- fisheye(x = z, centre = x[x$ADM0_A3 %in% "NGA",], k = 6) mf_export(zNGA, "nigeria.png", theme = "green") mf_map(zNGA, col = "white", border ="white", add = T) mf_map(xNGA, col = "lightblue", border = "white", lwd = .7, add = T) mf_map(xNGA, "POP_EST", "prop", border = "grey80", inches = .3, leg_title = "Population", leg_frame = T) mf_title("Transformed map, center = Nigeria") dev.off() xCHE <- fisheye(x = x, centre = x[x$ADM0_A3 %in% "CHE",], k = 6) zCHE <- fisheye(x = z, centre = x[x$ADM0_A3 %in% "CHE",], k = 6) mf_export(zCHE, "switzerland.png", theme = "green") mf_map(zCHE, col = "white", border ="white", add = T) mf_map(xCHE, col = "lightblue", border = "white", lwd = .7, add = T) mf_map(xCHE, "POP_EST", "prop", border = "grey80", inches = .3, leg_title = "Population", leg_frame = T) mf_title("Transformed map, center = Switzerland") dev.off()