adeckmyn / maps Goto Github PK
View Code? Open in Web Editor NEWR package for geographical maps
R package for geographical maps
Hi!
I think e and I were inverted for city Canico. It should be Madeira, not Madiera. All the other cities like Santa Cruz are well put in Madeira.
Also I see references to country Serbia and Montenegro, which does not exist anymore. Shouldn't it be split into Republic of Serbia, Montenegro, and perhaps Kosovo, like in the following proposal:
name;country.etc;pop;lat;long;capital
Ada;Republic of Serbia;10160;45.8;20.13;0
Aleksandrovac;Republic of Serbia;6632;43.46;21.05;0
Aleksinac;Republic of Serbia;16641;43.54;21.71;0
Aleksinacki Rudnik;Republic of Serbia;1417;43.56;21.69;0
Alibunar;Republic of Serbia;3335;45.08;20.97;0
Apatin;Republic of Serbia;19804;45.67;18.98;0
Arandelovac;Republic of Serbia;24782;44.31;20.57;0
Arilje;Republic of Serbia;6985;43.75;20.1;0
Azanja;Republic of Serbia;4567;44.43;20.88;0
Babusnica;Republic of Serbia;4629;43.06;22.41;0
Bac;Republic of Serbia;6129;45.39;19.24;0
Backa Palanka;Republic of Serbia;30470;45.25;19.39;0
Backa Topola;Republic of Serbia;16052;45.82;19.64;0
Backi Jarak;Republic of Serbia;6321;45.37;19.88;0
Backi Petrovac;Republic of Serbia;6618;45.36;19.59;0
Backo Gradiste;Republic of Serbia;5451;45.53;20.03;0
Backo Petrovo Selo;Republic of Serbia;7078;45.71;20.08;0
Badovinci;Republic of Serbia;5396;44.79;19.37;0
Bajina Basta;Republic of Serbia;9910;43.97;19.57;0
Bajmok;Republic of Serbia;8612;45.97;19.42;0
Baljevac;Republic of Serbia;1625;43.39;20.64;0
Banatski Karlovac;Republic of Serbia;5792;45.05;21.02;0
Banatsko Novo Selo;Republic of Serbia;7388;44.99;20.78;0
Banja Koviljaca;Republic of Serbia;6632;44.51;19.16;0
Barajevo;Republic of Serbia;9051;44.58;20.42;0
Baric;Republic of Serbia;6908;44.65;20.26;0
Batocina;Republic of Serbia;5637;44.15;21.08;0
Bavaniste;Republic of Serbia;6013;44.82;20.88;0
Becej;Republic of Serbia;25509;45.63;20.04;0
Bela Crkva;Republic of Serbia;10565;44.9;21.42;0
Bela Palanka;Republic of Serbia;8791;43.22;22.31;0
Belgrade;Republic of Serbia;1113589;44.83;20.5;1
Beli Potok;Republic of Serbia;3692;43.54;22.08;0
Beocin;Republic of Serbia;8148;45.2;19.72;0
Beska;Republic of Serbia;6359;45.13;20.07;0
Bezdan;Republic of Serbia;5270;45.85;18.93;0
Blace;Republic of Serbia;5626;43.3;21.29;0
Bogatic;Republic of Serbia;7376;44.84;19.48;0
Bogovina;Republic of Serbia;1178;43.9;21.94;0
Bolec;Republic of Serbia;6157;44.72;20.6;0
Boljevac;Republic of Serbia;3761;43.83;21.95;0
Bor;Republic of Serbia;39360;44.13;22.1;0
Borca;Republic of Serbia;38842;44.87;20.45;0
Bosilegrad;Republic of Serbia;2732;42.5;22.47;0
Brus;Republic of Serbia;4657;43.38;21.03;0
Brza Palanka;Republic of Serbia;1048;44.47;22.45;0
Brzi Brod;Republic of Serbia;4738;43.31;21.97;0
Bujanovac;Republic of Serbia;12116;42.46;21.77;0
Cacak;Republic of Serbia;75650;43.9;20.33;0
Cajetina;Republic of Serbia;3364;43.75;19.72;0
Cantavir;Republic of Serbia;6985;45.92;19.76;0
Celarevo;Republic of Serbia;5599;45.27;19.53;0
Cicevac;Republic of Serbia;5010;43.72;21.45;0
Coka;Republic of Serbia;4581;45.94;20.14;0
Crepaja;Republic of Serbia;4775;45.01;20.64;0
Crvenka;Republic of Serbia;10141;45.66;19.46;0
Cuprija;Republic of Serbia;20355;43.93;21.38;0
Curug;Republic of Serbia;8886;45.47;20.07;0
Dakovica;Kosovo;97156;42.39;20.43;0
Despotovac;Republic of Serbia;4539;44.09;21.45;0
Dimitrovgrad;Republic of Serbia;6864;43.01;22.78;0
Dobanovci;Republic of Serbia;8250;44.83;20.23;0
Dolovo;Republic of Serbia;6874;44.9;20.88;0
Donja Vrezina;Republic of Serbia;4859;43.33;21.95;0
Donji Komren;Republic of Serbia;6057;43.35;21.88;0
Donji Milanovac;Republic of Serbia;3055;44.48;22.12;0
Durdevo;Republic of Serbia;5357;45.32;20.06;0
Futog;Republic of Serbia;19632;45.24;19.71;0
Gnjilane;Kosovo;91595;42.47;21.48;0
Golubinci;Republic of Serbia;5434;44.99;20.77;0
Gornji Milanovac;Republic of Serbia;24757;44.03;20.46;0
Grdelica;Republic of Serbia;2369;42.9;22.07;0
Grocka;Republic of Serbia;8661;44.67;20.72;0
Guca;Republic of Serbia;2013;43.78;20.23;0
Horgos;Hungary;6062;46.16;19.97;0
Indija;Republic of Serbia;27569;45.05;20.09;0
Irig;Republic of Serbia;5033;45.1;19.86;0
Ivanjica;Republic of Serbia;12783;43.58;20.23;0
Jabuka;Republic of Serbia;6211;43.35;19.52;0
Jagodina;Republic of Serbia;35190;43.98;21.26;0
Jakovo;Republic of Serbia;6122;44.76;20.26;0
Jasa Tomic;Romania;2842;45.45;20.86;0
Josanicka Banja;Republic of Serbia;1142;43.39;20.75;0
Kac;Republic of Serbia;11801;45.3;19.94;0
Kacarevo;Republic of Serbia;7536;44.97;20.69;0
Kaluderica;Republic of Serbia;24229;44.75;20.57;0
Kanjiza;Republic of Serbia;9894;46.07;20.05;0
Karavukovo;Republic of Serbia;4859;45.5;19.19;0
Kikinda;Republic of Serbia;41650;45.84;20.45;0
Kisac;Republic of Serbia;5369;45.35;19.73;0
Kladovo;Republic of Serbia;9042;44.61;22.61;0
Kljajicevo;Republic of Serbia;6151;45.77;19.28;0
Klupci;Republic of Serbia;7430;44.53;19.25;0
Knjazevac;Republic of Serbia;19392;43.57;22.26;0
Koceljeva;Republic of Serbia;4793;44.47;19.81;0
Kosjeric;Republic of Serbia;4231;44;19.91;0
Kosovo Polje;Kosovo;33276;42.63;21.12;0
Kosovska Mitrovica;Kosovo;86359;42.89;20.87;0
Kostolac;Republic of Serbia;9197;44.71;21.17;0
Kovacica;Republic of Serbia;6657;45.11;20.62;0
Kovilj;Republic of Serbia;5773;45.23;20.02;0
Kovin;Republic of Serbia;14550;44.75;20.98;0
Kragujevac;Republic of Serbia;150218;44.02;20.92;0
Kraljevo;Republic of Serbia;58247;43.74;20.67;0
Krupanj;Republic of Serbia;4925;44.37;19.36;0
Krusevac;Republic of Serbia;57407;43.58;21.32;0
Kucevo;Republic of Serbia;4560;44.48;21.67;0
Kucura;Republic of Serbia;4657;45.52;19.59;0
Kula;Republic of Serbia;19423;45.62;19.52;0
Kursumlija;Republic of Serbia;14091;43.15;21.27;0
Kusadak;Republic of Serbia;5606;44.4;20.8;0
Lacarak;Republic of Serbia;11263;45;19.57;0
Lajkovac;Republic of Serbia;3453;44.37;20.17;0
Lapovo;Republic of Serbia;7265;44.18;21.1;0
Lazarevac;Republic of Serbia;24792;44.39;20.27;0
Lebane;Republic of Serbia;10129;42.92;21.74;0
Leskovac;Republic of Serbia;63846;43;21.95;0
Lesnica;Republic of Serbia;4727;44.65;19.31;0
Lestane;Republic of Serbia;9207;44.73;20.58;0
Ljig;Republic of Serbia;3085;44.22;20.24;0
Ljubovija;Bosnia and Herzegovina;4286;44.19;19.38;0
Loznica;Republic of Serbia;21484;44.53;19.22;0
Loznicko Polje;Republic of Serbia;7899;44.56;19.22;0
Lozovik;Republic of Serbia;5520;44.46;21.1;0
Lucani;Republic of Serbia;4337;43.86;20.14;0
Macvanska Mitrovica;Republic of Serbia;3875;44.97;19.6;0
Majdanpek;Republic of Serbia;9471;44.42;21.94;0
Majur;Republic of Serbia;7057;44.77;19.65;0
Mali Idos;Republic of Serbia;5393;45.71;19.67;0
Mali Zvornik;Bosnia and Herzegovina;4921;44.4;19.12;0
Mataruska Banja;Republic of Serbia;2940;43.69;20.61;0
Medveda;Republic of Serbia;2742;43.63;21.08;0
Melenci;Republic of Serbia;6394;45.51;20.32;0
Mionica;Republic of Serbia;1731;44.25;20.08;0
Mladenovac;Republic of Serbia;22063;44.43;20.7;0
Mokrin;Republic of Serbia;5807;45.94;20.41;0
Mol;Republic of Serbia;6602;45.76;20.13;0
Negotin;Republic of Serbia;18077;44.23;22.53;0
Niksic;Montenegro;66621;42.78;18.94;0
Nis;Republic of Serbia;173835;43.33;21.9;0
Niska Banja;Republic of Serbia;4554;43.3;22.02;0
Nova Pazova;Republic of Serbia;19249;44.94;20.22;0
Nova Varos;Republic of Serbia;10144;43.46;19.81;0
Novi Banovci;Republic of Serbia;10749;44.95;20.28;0
Novi Becej;Republic of Serbia;14183;45.6;20.14;0
Novi Knezevac;Republic of Serbia;7473;46.05;20.1;0
Novi Pazar;Republic of Serbia;56495;43.15;20.52;0
Novi Sad;Republic of Serbia;195657;45.25;19.85;0
Novo Milosevo;Republic of Serbia;6626;45.72;20.3;0
Obrenovac;Republic of Serbia;24478;44.66;20.21;0
Odzaci;Republic of Serbia;9718;45.51;19.26;0
Omoljica;Republic of Serbia;6485;44.76;20.73;0
Opovo;Republic of Serbia;4653;45.05;20.43;0
Orahovac;Kosovo;26598;42.41;20.66;0
Osecina;Republic of Serbia;3303;44.37;19.6;0
Ostruznica;Republic of Serbia;4030;44.73;20.32;0
Ovca;Republic of Serbia;2299;44.89;20.54;0
Padina;Republic of Serbia;5717;45.12;20.73;0
Padinska Skela;Republic of Serbia;9304;44.94;20.43;0
Palic;Republic of Serbia;7872;46.11;19.77;0
Pancevo;Republic of Serbia;77562;44.87;20.66;0
Paracin;Republic of Serbia;25450;43.87;21.41;0
Pec;Kosovo;95190;42.66;20.31;0
Petrovac;Republic of Serbia;7981;44.39;21.41;0
Petrovaradin;Republic of Serbia;15092;45.25;19.88;0
Pinosava;Republic of Serbia;2886;44.7;20.48;0
Pirot;Republic of Serbia;41011;43.17;22.6;0
Pljevlja;Montenegro;26748;43.36;19.36;0
Pocerski Pricinovic;Republic of Serbia;6253;44.73;19.7;0
Podgorica;Montenegro;160103;42.47;19.28;0
Podujevo;Kosovo;48526;42.91;21.19;0
Pozarevac;Republic of Serbia;42105;44.63;21.19;0
Pozega;Republic of Serbia;13467;43.85;20.04;0
Predejane;Republic of Serbia;1160;42.83;22.13;0
Presevo;Republic of Serbia;13544;42.31;21.65;0
Priboj;Republic of Serbia;19002;43.59;19.54;0
Prigrevica;Republic of Serbia;4814;45.68;19.09;0
Prijepolje;Republic of Serbia;14757;43.39;19.65;0
Pristina;Kosovo;262686;42.65;21.17;0
Prizren;Kosovo;165227;42.23;20.74;0
Prokuplje;Republic of Serbia;26895;43.24;21.59;0
Raca;Republic of Serbia;2765;44.92;19.29;0
Radinac;Republic of Serbia;4924;44.63;20.97;0
Raska;Republic of Serbia;6635;43.29;20.62;0
Resavica;Republic of Serbia;2291;44.07;21.52;0
Ribnica;Republic of Serbia;2778;43.71;20.69;0
Ripanj;Republic of Serbia;10858;44.64;20.52;0
Rudovci;Republic of Serbia;1778;44.37;20.42;0
Ruma;Republic of Serbia;33458;45;19.83;0
Rumenka;Republic of Serbia;6291;45.29;19.74;0
Rusanj;Republic of Serbia;4864;44.68;20.44;0
Ruski Krstur;Republic of Serbia;5096;45.56;19.42;0
Sabac;Republic of Serbia;55195;44.76;19.69;0
Sajkas;Republic of Serbia;4869;45.27;20.09;0
Senta;Republic of Serbia;19727;45.94;20.09;0
Sevojno;Republic of Serbia;7779;43.85;19.9;0
Sid;Republic of Serbia;17155;45.13;19.23;0
Sivac;Republic of Serbia;8866;45.7;19.38;0
Sjenica;Republic of Serbia;12807;43.27;20;0
Smederevo;Republic of Serbia;63161;44.67;20.93;0
Smederevska Palanka;Republic of Serbia;25577;44.37;20.96;0
Sokobanja;Republic of Serbia;8307;43.64;21.87;0
Sombor;Republic of Serbia;51825;45.78;19.12;0
Sonta;Republic of Serbia;4841;45.59;19.1;0
Sopot;Republic of Serbia;1779;44.52;20.57;0
Srbobran;Republic of Serbia;13207;45.55;19.8;0
Sremcica;Republic of Serbia;19321;44.68;20.39;0
Sremska Kamenica;Republic of Serbia;12609;45.22;19.84;0
Sremska Mitrovica;Republic of Serbia;39361;44.98;19.61;0
Sremski Karlovci;Republic of Serbia;9398;45.2;19.93;0
Stanisic;Republic of Serbia;4729;45.94;19.17;0
Stara Moravica;Republic of Serbia;5518;45.87;19.47;0
Stara Pazova;Republic of Serbia;19369;44.99;20.16;0
Starcevo;Republic of Serbia;7642;44.81;20.7;0
Stari Banovci;Republic of Serbia;6085;44.99;20.29;0
Subotica;Republic of Serbia;99618;46.07;19.68;0
Surcin;Republic of Serbia;15094;44.79;20.28;0
Surdulica;Republic of Serbia;10788;42.69;22.17;0
Svilajnac;Republic of Serbia;9759;44.23;21.2;0
Svrljig;Republic of Serbia;7847;43.41;22.12;0
Temerin;Republic of Serbia;20127;45.41;19.89;0
Titel;Republic of Serbia;5829;45.21;20.29;0
Topola;Republic of Serbia;5750;44.25;20.68;0
Trstenik;Republic of Serbia;17342;43.62;21.01;0
Tutin;Republic of Serbia;9258;42.99;20.33;0
Ub;Republic of Serbia;6106;44.46;20.07;0
Ugrinovci;Republic of Serbia;8270;44.88;20.19;0
Umka;Republic of Serbia;5369;44.68;20.3;0
Urosevac;Kosovo;97741;42.38;21.17;0
Uzice;Republic of Serbia;55864;43.87;19.84;0
Valjevo;Republic of Serbia;62807;44.28;19.89;0
Velika Plana;Republic of Serbia;16128;44.33;21.07;0
Veliki Crljeni;Republic of Serbia;4566;44.47;20.28;0
Veliki Trnovac;Republic of Serbia;6816;42.48;21.74;0
Veliko Gradiste;Republic of Serbia;5775;44.76;21.51;0
Veternik;Republic of Serbia;21937;45.25;19.76;0
Vinca;Republic of Serbia;6098;44.76;20.62;0
Vladicin Han;Republic of Serbia;8499;42.71;22.06;0
Vlasotince;Republic of Serbia;16830;42.96;22.12;0
Vojka;Republic of Serbia;5217;44.94;20.15;0
Vranje;Republic of Serbia;56583;42.57;21.91;0
Vranjska Banja;Republic of Serbia;6189;42.56;21.99;0
Vrbas;Republic of Serbia;26020;45.57;19.65;0
Vrcin;Republic of Serbia;9048;44.67;20.59;0
Vrnjacka Banja;Republic of Serbia;10025;43.62;20.9;0
Vrsac;Republic of Serbia;36044;45.13;21.3;0
Vucje;Republic of Serbia;3172;42.87;21.91;0
Zabalj;Republic of Serbia;9932;45.37;20.06;0
Zajecar;Republic of Serbia;39894;43.91;22.3;0
Zitiste;Republic of Serbia;3316;45.49;20.55;0
Zlatibor;Republic of Serbia;2565;43.72;19.7;0
Zrenjanin;Republic of Serbia;79346;45.37;20.4;0
Zvecka;Republic of Serbia;6192;44.64;20.16;0
Thanks!
Sebastien
The original source of "world.cities" is no longer available. The best free online source is probably geonames.org
The cities5000 data set has about the same number of entries as world.cities (~40,000) of which about half coincide. So it is not identical, but at least has some more recent data and quality control.
Hi,
I would like to use my own shape file in map() function.
can anybody guide me to create database of my shape file.
shape file is attached here.
World-India.zip
Thanks & regards,
M. Sateesh
NCMRWF, India.
Output of map() is a list with elements $x, $y, $names (and $range). If the lines are not closed polygons (fill=TRUE), you loose all polygon information and the list is of limited use afterwards.
Adding an extra $gondata which describes how the lines may be combined, could remedy this somewhat. But there are caveats. For instance, map(...,fill=FALSE) may return loose end that don't even form a polygon.
Having proj4 support in 'maps' would be useful. But it probably can only exist besides the old projection library, which for compatibility reasons can not be removed easily. So I will probably just add new options map(..., proj4="", proj4inv=FALSE)
The second allows for inverse projections of your data (which mapproj doesn't even implement)
In a clean R session,
> maps::map("state")
produces the error:
Error in maptype(database) : object 'C_map_type' not found
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] maps_3.2.0.9000
loaded via a namespace (and not attached):
[1] compiler_3.4.2 tools_3.4.2 yaml_2.1.14
Loading the package and referencing the function directly also produces the same error:
Show in New WindowClear OutputExpand/Collapse Output
Error in try_require("maps", "map_data") :
could not find function "try_require"
Show in New WindowClear OutputExpand/Collapse Output
Google Maps API Terms of Service: http://developers.google.com/maps/terms.
Please cite ggmap if you use it: see citation('ggmap') for details.
Attaching package: �ggmap�
The following object is masked from �package:magrittr�:
inset
Modify Chunk OptionsRun Current ChunkModify Chunk OptionsRun All Chunks AboveRun Current Chunk
Expand/Collapse Output
ConsoleU:/Analysis/Presentations/
Console
Terminal
U:/Analysis/Presentations/
> library(maps)
> map("state")
Error in maptype(database) : object 'C_map_type' not found
Hi there,
Noticing an issue with some counties not appearing when visualizing US Counties. The county that caught my attention was Oglala Lakota County, in South Dakota (STATECOUNTYFIPS: 46102), but given that there are 3143 counties in the Census ACS data and only 3085 in the maps county.fips table, I imagine others are also missing.
FIPS code should be 02
Just a small item: in src/county.name
the entry south dakota,oglala dakota
should be south dakota,oglala lakota
.
If I try to add only "Loire" to a region, it's gonna also add Loire, Loire-Atlantique, and Loiret to the map
Might have to do with the code searching for all regions starting with the same argument
here's the command I did :
map(database="france",region=c("Loire"))
I'm currently trying to make a custom map from US Census Tracts and I'm wondering if there's a way to thin or completely remove lines between polygons. There are 70,000+ tracts, and I'm worried they will make the map unreadable.
Bonus question/issue: Is there a simple tutorial for turning a shapefile into a map for maps? I'm admittedly not the most skilled person with spatial geography, but I think there's a lot of value in a Census Tract map for analysis.
Hello. I think "Seoul", the capital city of South Korea, is incorrectly listed as "Soul" in the world.cities dataset. Could we correct this error?
world.cities %>%
Thanks!
Taesim
There are some changes in ISO3166 that should be implemented. Some of the weird regex constructions in the main data frame are very confusing.
Here is my code:
library(tidyverse)
library(maps)
library(ggmap)
us<- map_data("state")
And here is the result:
Error in .C(C_map_getg, as.character(mapbase), gons = as.integer(gons), :
Incorrect number of arguments (7), expecting 1769234798 for 'kernel_smooth'
I'm on the latest version of R and all packages.
I see 'world' and 'italy' have non unique values for 'names', which makes it hard to keep track of what parts belong to each "object".
I haven't been comprehensive, just looked at a set of the dbs in the maps package below. The non unique values are listed at the end.
Is it sensible to update and fix these manually? Are you interested to check the behaviour in mapdata and other dbs for this package generally?
I want to be able to create 'sp' and 'ggplot2' types and other formats from these data sets, and so I'd like to know if my conclusion is correct before I continue.
library(maps) ## maps_3.1.1 from CRAN
getm <- function(nm) {
map(nm, plot = FALSE, fill = TRUE)
}
dbs <- c("world", "usa", "state", "county", "france", "italy", "legacy_world",
"legacy_world2", "nz", "state.carto")
l <- vector("list", length(dbs))
for (i in seq_along(dbs)) {
x <- getm(dbs[i])
## detect all NAs in coords
bad <- is.na(x$x)
## count instances of NA (assume same for y)
seqs <- sum(bad) + 1
## tabulate the unique sequences between the missing values
## (this is a check on whether there are runs of NA)
counts <- table((cumsum(bad) + 1)[!bad])
## the count of unique names
nnames <- length(unique(x$names))
l[[i]] <- data.frame(name = dbs[i], nseqs = seqs, ncounts = length(counts),
names = nnames,
stringsAsFactors = FALSE)
}
do.call(rbind, l)
name nseqs ncounts names
1 world 1627 1627 1625
2 usa 10 10 10
3 state 63 63 63
4 county 3085 3085 3085
5 france 114 114 114
6 italy 133 133 125
7 legacy_world 2284 2284 2026
8 legacy_world2 2284 2284 2026
9 nz 22 22 22
10 state.carto 50 50 50
## world
world <- map("world", fill = TRUE, plot = FALSE)
world$names[duplicated(world$names)]
#[1] "San Marino" "Vatican"
## italy
italy <- map("italy", fill = TRUE, plot = FALSE)
italy$names[duplicated(italy$names)]
#[1] "Udine" "Gorizia" "Venezia" "Venezia" "Arezzo"
#[6] "Avellino" "Sassari" "Caltanissetta"
I realize it's a different behaviour for fill = FALSE, but as far as I can see in that case the "names" vector is not useable, not related to the lists of NA-separated paths any more? Is that right?
HI @adeckmyn ,
Thanks for your maps and mapmaker packages. I've recently used your workflow to create a custom map package for New York City but would like your thoughts on the best way to register the map.
I tried to follow the zzz.R file but had a bit of trouble being able to call maps so resorted to modifying my .GlobalEnv. I know thats a no-no so I was wondering if you have some thoughts on a good pattern for registering new map data.
# from zzz.R in nycmaps
.onLoad <- function(lib, pkg) {
if (Sys.getenv("R_MAP_DATA_DIR") == "")
Sys.setenv("R_MAP_DATA_DIR" = paste(lib, pkg, "mapdata/", sep="/"))
## temporarily, we add the possibility of changing for "world" only,
## to point at the /legacy subdirectory
if (Sys.getenv("R_MAP_DATA_DIR_WORLD") == "") {
if(Sys.getenv("R_MAP_DATA_LEGACY")=="TRUE") Sys.setenv("R_MAP_DATA_DIR_WORLD" = paste(Sys.getenv("R_MAP_DATA_DIR"), "legacy_",sep=""))
else Sys.setenv("R_MAP_DATA_DIR_WORLD" = Sys.getenv("R_MAP_DATA_DIR"))
}
#include map libraries
library.dynam("maps", "maps", lib)
# set the environment to allow access to maps.
# this is a bit clunky. is there a better way?
Sys.setenv("NY_MAPS"= paste(lib, pkg, "mapdata/", sep="/"))
Sys.setenv("nycMapEnv"="NY_MAPS")
assign("nycMapEnv","NY_MAPS", envir = .GlobalEnv)
}
Thanks
zach cp
Currently only SpatialPolygons are supported. But SpatialLines objects should be included as well. E.g. rnaturalearth includes coastlineNN as SpatialLinesDataFrame.
Why is this happening?
maps::map.where('world', -73.97058, 40.76813)
## "USA"
maps::map.where('world', -73.59143, 40.74178)
## "USA:New York:Long Island"
Why does the second call return more than just USA?
link to: https://stackoverflow.com/questions/50875944/map-whereworld-x-y-returning-more-than-just-country
First, thank you for this very useful package.
I am working with large data sets and unavoidably, some will have missing values. It would be useful if the map.where
function had an argument to output NA instead of throwing an error in the presence of missing values.
library(maps)
df <- data.frame(x = c(-82.0582, 82.0582), y = c(41, 41))
map.where(x = df$x, y = df$y)
#> [1] "USA" "China"
df <- data.frame(x = c(-82.0582, 82.0582), y = c(41, NA))
map.where(x = df$x, y = df$y)
#> Error in map.where(x = df$x, y = df$y): NA/NaN/Inf in foreign function call (arg 3)
df <- data.frame(x = c(-82.0582, ""), y = c(41, 41))
map.where(x = df$x, y = df$y)
#> Error in map.where(x = df$x, y = df$y): NA/NaN/Inf in foreign function call (arg 2)
map.where(x = NA, y = 41)
#> Error in map.where(x = NA, y = 41): NA/NaN/Inf in foreign function call (arg 2)
map.where(x = "", y = 41)
#> Error in map.where(x = "", y = 41): NA/NaN/Inf in foreign function call (arg 2)
Created on 2022-10-31 with reprex v2.0.2
In large data frames, that would make it more convenient to process it correctly if the information is available, and add an NA if not. Right now, it causes an error so it makes it more difficult to use. Is there already such an argument that I may have missed from the documentation?
Hello. The two mentioned islands associated with Puerto Rico are incorrectly identified/ spelled.
The island you spelled as "Viaques" should be "Vieques"
Mona island should be "Isla de la Mona"
Note that on the Map of Puerto Rico you are missing the island of Culebra.
Support for SpatialPolygons object is still basic. map() works OK, but other functions may not.
Hello,
I have been using maps for a current research project. I love the package, and it has saved so much time automating some maps that would otherwise be time consuming.
I have a question that I have been unable to find out. There is a bonding box/neatline surrounding my plot that I would like to get rid of. I cannot seem to find the property that would remove it.
Here is a screenshot of what the map looks like and what I am trying to remove is the black square.
Attached is the code. I am using the most updated version of maps and version 3.6.1 for r.
`library("knitr")
library(latticeExtra) # USCancerRates, mapplot
library(maps) # map
library(classInt) # classIntervals, findCols
library(grid) # viewport, pushViewport
library(pals) # brewer.blues, stevens.pinkgreen
library(sf)
library(maptools)
#Decide scheme
cols <- tolochko.redblue; nbins <- 3
#load data
df = read_sf('cities/atlanta_bi.shp')
#Create breaks
brks_d <- classIntervals(df$cbg_o_medi, n=nbins, style='jenks')
brks_o <- classIntervals(df$entropy, n=nbins, style='jenks')
#Create new classes
d <- findCols(brks_d)
o <- findCols(brks_o)
df$bi <- d + nbins*(o-1)
#Create Map
shp = readShapePoly('cities/atlanta_bi.shp')
m3 <- mapplot(rownames(df) ~ bi, data = df,
colramp=cols, breaks=seq(from=0.5, by=1, length=nbins*nbins+1),
xlab="",
colorkey=FALSE,
type='polygon',
border = '#DEDEDE',
drawBox = FALSE,
map = map(shp, plot = FALSE, fill = TRUE,
projection = "tetra"),
scales = list(draw = FALSE))
#suppressWarnings(print( m3 ))
x.scale <- list(cex=1)
y.scale <- list(cex=1)
m3leg <- levelplot(matrix(1:(nbins*nbins), nrow=nbins), axes=FALSE, col.regions=cols(),
xlab=list("median distance -->", cex=0.6), ylab=list("entropy -->", cex=0.6), cuts=8, colorkey=FALSE,
scales=list(draw=0))
finalPlot <- ggdraw() +
draw_plot(m3, 0,0,1,1) +
draw_plot(m3leg,0,0, 0.2, 0.2)
ggsave("Atlanta_Distance_Entropy.png", finalPlot,dpi=300)
#vp <- viewport(x=.15, y=.25, width=.2, height=.2)
#pushViewport(vp)
#print(m3leg, newpage=FALSE)
#popViewport()`
Attached here is the shapefile that I am using (Please note that you may have to change the path on lines 14 and 29 of the code if you try to reproduce this.
atlanta_bi.zip
My OS is windows 10.
Please let me know if I am missing anything. Thank you for your help!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.