Cookies help us display personalized product recommendations and ensure you have great shopping experience.

By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData CollectiveSmartData Collective
  • Analytics
    AnalyticsShow More
    How a Specialized Marketing VA Improves Campaign Analytics
    How a Specialized Marketing VA Improves Campaign Analytics
    11 Min Read
    New Data Analytics Breakthroughs Give eCommerce Startups a Fighting Chance
    New Data Analytics Breakthroughs Give eCommerce Startups a Fighting Chance
    6 Min Read
    How Data Analytics Is Reshaping Patient Financing Decisions
    How Data Analytics Is Reshaping Patient Financing Decisions
    13 Min Read
    business using business intelligence
    How to Use a Competitive Intelligence Dashboard to Turn Market Data Into Smarter Marketing Decisions 
    9 Min Read
    unusual trading activity
    Signal Or Noise? A Decision Tree For Evaluating Unusual Trading Activity
    3 Min Read
  • Big Data
  • BI
  • Exclusive
  • IT
  • Marketing
  • Software
Search
© 2008-25 SmartData Collective. All Rights Reserved.
Reading: Geographic maps in R
Share
Notification
Font ResizerAa
SmartData CollectiveSmartData Collective
Font ResizerAa
Search
  • About
  • Help
  • Privacy
Follow US
© 2008-23 SmartData Collective. All Rights Reserved.
SmartData Collective > Big Data > Data Visualization > Geographic maps in R
Data Visualization

Geographic maps in R

DavidMSmith
DavidMSmith
3 Min Read
SHARE

The maps library for R is a powerful tool for creating maps of countries and regions of the world. For example, you can create a map of the USA and its states in just three lines of code:

library(maps)

map(“state”, interior = FALSE)

More Read

Great Visualization of One Hour of Carbon Emissions in NYC….
Bad Data Viz – That’s No Pie Chart
Art and Science of Data Visualization
Growth in Data-Related Jobs, cnt’d
Analytics-based Presidential Campaigns

map(“state”, boundary = FALSE, col=“gray”, add = TRUE)

USA map

The coordinate system of the graph is latitude and longitude, so it’s easy to overlay other spatial data on this map.

Unfortunately, the data for the maps library isn’t sufficient for some applications. The maps themselves are fairly low-resolution (although higher-resolution data is available in the mapdata package), and political boundaries can be incomplete or out-of-date. Luckily, there are now free online resources where you can find updated map data for use with R … 



The maps library for R is a powerful tool for creating maps of countries and regions of the world. For example, you can create a map of the USA and its states in just three lines of code:

library(maps)

map(“state”, interior = FALSE)

map(“state”, boundary = FALSE, col=“gray”, add = TRUE)

USA map

The coordinate system of the graph is latitude and longitude, so it’s easy to overlay other spatial data on this map.

Unfortunately, the data for the maps library isn’t sufficient for some applications. The maps themselves are fairly low-resolution (although higher-resolution data is available in the mapdata package), and political boundaries can be incomplete or out-of-date. Luckily, there are now free online resources where you can find updated map data for use with R. 

GADM is a spatial database of the location of the world’s administrative boundaries, and as Claudia Engel discovered the map information is available as native R objects that can be plotted directly with the spplot function (from the sp package). For example, here’s how to load the data for Switzerland, and then plot each canton with a color denoting its primary language:

library(sp)
con <- url(“http://gadm.org/data/rda/CHE_adm1.RData”)
print(load(con))
close(con)

language <- c(“german”, “german”, “german”,“german”,
 “german”,“german”,“french”, “french”,
 “german”,“german”,“french”, “french”, 
 “german”, “french”,“german”,“german”,
 “german”,“german”,“german”, “german”,
 “german”,“italian”,“german”,“french”,
 “french”,“german”,“german”)
gadm$language <- as.factor(language)
col = rainbow(length(levels(gadm$language)))
spplot(gadm, “language”, col.regions=col, main=“Swiss Language Regions”)

    Swiss_lang
    Sweet!

    AnthroSpace: Download Global Administrative Areas as RData files

    Link to original post

    TAGGED:r language
    Share This Article
    Facebook Pinterest LinkedIn
    Share

    Follow us on Facebook

    Latest News

    How a Specialized Marketing VA Improves Campaign Analytics
    How a Specialized Marketing VA Improves Campaign Analytics
    Analytics Exclusive
    ai marketing tools
    The 9 AI Tools Marketers Use to Create Images and Video in 2026
    Artificial Intelligence Exclusive
    ai chatbot
    How AI Website Chatbots Improve Customer Support and Lead Generation
    Chatbots Exclusive
    Why Every Small Business Should Care About an AI Image Generator
    Why Every Small Business Should Care About an AI Image Generator
    Artificial Intelligence Exclusive

    Stay Connected

    1.2KFollowersLike
    33.7KFollowersFollow
    222FollowersPin

    You Might also Like

    R Script Creates a Map of Worldwide Email Traffic

    3 Min Read

    A Data Scientist Investigates the Belgian Municipal Elections

    13 Min Read

    Adventures in MOOC: Back to School

    4 Min Read
    first data scientist Norman Nie
    AnalyticsBig DataHadoop

    The First Data Scientist on the Evolution of Data Science

    11 Min Read

    SmartData Collective is one of the largest & trusted community covering technical content about Big Data, BI, Cloud, Analytics, Artificial Intelligence, IoT & more.

    ai in ecommerce
    Artificial Intelligence for eCommerce: A Closer Look
    Artificial Intelligence
    AI and chatbots
    Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
    Artificial Intelligence Chatbots Exclusive

    Quick Link

    • About
    • Contact
    • Privacy
    Follow US
    © 2008-26 SmartData Collective. All Rights Reserved.
    Welcome Back!

    Sign in to your account

    Username or Email Address
    Password

    Lost your password?