Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updated world map for R "maps" package?

Tags:

r

maps

geospatial

library(maps)
1> map.where(database="world",29.392089,53.592505)
[1] "USSR"

does anyone know how I can get an updated world map database to drive this function in the maps package? I need country names only for now, not detailed sub-national administrative information such as is available in at gadm.org.

like image 280
generic_user Avatar asked Apr 02 '13 06:04

generic_user


1 Answers

Try wrld_simpl in the maptools package.

require(maptools)
data(wrld_simpl)
plot(wrld_simpl)

## or subset based on the name
plot(wrld_simpl[wrld_simpl$NAME == "Russia", ])
## explore other attributes
summary(wrld_simpl)

I don't know how up to date it is, but ?wrld_simpl describes the source so you might find good stuff following links. Other packages that rely on sp will also be worth exploring for data.

Otherwise, there was the Rgshhs package, though I'm not sure that's still available. It came with fair detail but you can download more if you need it. It's a bit complicated, the original data is here: http://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html

You can also read in data from vector formats (like MIF or SHP or PostGIS) using rgdal if you have your own data, or similar read functions in maptools for shapefile only.

Example to query the objects using points:

require(sp)
require(maptools)
data(wrld_simpl)
pts <- SpatialPoints(cbind(c(29.392089,147), c(53.592505, -35)), CRS(proj4string(wrld_simpl)))

over(pts, wrld_simpl)$NAME

For an introduction to these and other functions in sp see vignette("sp").

Also try the geonames package for more general querying of geographic names.

like image 178
mdsumner Avatar answered Oct 16 '22 11:10

mdsumner