By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData Collective
  • Analytics
    AnalyticsShow More
    data analytics in sports industry
    Here’s How Data Analytics In Sports Is Changing The Game
    6 Min Read
    data analytics on nursing career
    Advances in Data Analytics Are Rapidly Transforming Nursing
    8 Min Read
    data analytics reveals the benefits of MBA
    Data Analytics Technology Proves Benefits of an MBA
    9 Min Read
    data-driven image seo
    Data Analytics Helps Marketers Substantially Boost Image SEO
    8 Min Read
    construction analytics
    5 Benefits of Analytics to Manage Commercial Construction
    5 Min Read
  • Big Data
  • BI
  • Exclusive
  • IT
  • Marketing
  • Software
Search
© 2008-23 SmartData Collective. All Rights Reserved.
Reading: Geographic maps in R
Share
Notification Show More
Latest News
data analytics in sports industry
Here’s How Data Analytics In Sports Is Changing The Game
Big Data
data analytics on nursing career
Advances in Data Analytics Are Rapidly Transforming Nursing
Analytics
data analytics reveals the benefits of MBA
Data Analytics Technology Proves Benefits of an MBA
Analytics
anti-spoofing tips
Anti-Spoofing is Crucial for Data-Driven Businesses
Security
ai in software development
3 AI-Based Strategies to Develop Software in Uncertain Times
Software
Aa
SmartData Collective
Aa
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
Last updated: 2009/10/21 at 1:33 PM
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)

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

More Read

Julia Language

Could the Julia Language Fill an Untapped Void for Big Data Programmers?

Microsoft and the Revolution: Analytics
Lots of Data Does Not Equal “Big Data”
NCAA Data Visualizer for March Madness Face-Offs
Open Data App for the Paris Métro

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
    DavidMSmith October 21, 2009
    Share this Article
    Facebook Twitter Pinterest LinkedIn
    Share

    Follow us on Facebook

    Latest News

    data analytics in sports industry
    Here’s How Data Analytics In Sports Is Changing The Game
    Big Data
    data analytics on nursing career
    Advances in Data Analytics Are Rapidly Transforming Nursing
    Analytics
    data analytics reveals the benefits of MBA
    Data Analytics Technology Proves Benefits of an MBA
    Analytics
    anti-spoofing tips
    Anti-Spoofing is Crucial for Data-Driven Businesses
    Security

    Stay Connected

    1.2k Followers Like
    33.7k Followers Follow
    222 Followers Pin

    You Might also Like

    Julia Language
    Big Data

    Could the Julia Language Fill an Untapped Void for Big Data Programmers?

    6 Min Read

    Microsoft and the Revolution: Analytics

    9 Min Read

    Lots of Data Does Not Equal “Big Data”

    7 Min Read

    NCAA Data Visualizer for March Madness Face-Offs

    2 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 chatbots
    AI Chatbots Can Help Retailers Convert Live Broadcast Viewers into Sales!
    Chatbots
    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-23 SmartData Collective. All Rights Reserved.

    Removed from reading list

    Undo
    Go to mobile version
    Welcome Back!

    Sign in to your account

    Lost your password?