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
    image fx (67)
    Improving LinkedIn Ad Strategies with Data Analytics
    9 Min Read
    big data and remote work
    Data Helps Speech-Language Pathologists Deliver Better Results
    6 Min Read
    data driven insights
    How Data-Driven Insights Are Addressing Gaps in Patient Communication and Equity
    8 Min Read
    pexels pavel danilyuk 8112119
    Data Analytics Is Revolutionizing Medical Credentialing
    8 Min Read
    data and seo
    Maximize SEO Success with Powerful Data Analytics Insights
    8 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

data visualization for small business
Data Visualization Boosts Business Scalability with Sales Mapping
Using Big Data Intelligently: Four Types of Discovery Technology
By the Data: The Geography of Gender-Based Income Inequality
Top 10 Powerful Data Modeling Tools For 2021
Mundaneum: the proto Web

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

    image fx (2)
    Monitoring Data Without Turning into Big Brother
    Big Data Exclusive
    image fx (71)
    The Power of AI for Personalization in Email
    Artificial Intelligence Exclusive Marketing
    image fx (67)
    Improving LinkedIn Ad Strategies with Data Analytics
    Analytics Big Data Exclusive Software
    big data and remote work
    Data Helps Speech-Language Pathologists Deliver Better Results
    Analytics Big Data Exclusive

    Stay Connected

    1.2kFollowersLike
    33.7kFollowersFollow
    222FollowersPin

    You Might also Like

    Microsoft and the Revolution: Analytics

    9 Min Read

    Visualizing Networks in R: Arc Diagrams and Hive Plots

    3 Min Read

    Video: Data Mining with R

    1 Min Read

    Votamatic Predicted the Presidential Election Results with R

    4 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 and chatbots
    Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
    Artificial Intelligence Chatbots Exclusive
    ai chatbot
    The Art of Conversation: Enhancing Chatbots with Advanced AI Prompts
    Chatbots

    Quick Link

    • About
    • Contact
    • Privacy
    Follow US
    © 2008-25 SmartData Collective. All Rights Reserved.
    Go to mobile version
    Welcome Back!

    Sign in to your account

    Username or Email Address
    Password

    Lost your password?