We use cookies, including third-party cookies from Google to serve personalized ads through AdSense, to operate this site and understand how it is used. By continuing to browse, you accept this use. See our Privacy Policy and Terms of Use for details, including how to opt out of personalized advertising.
Accept
SmartData CollectiveSmartData Collective
  • Analytics
    AnalyticsShow More: Analytics
    Cut-paper editorial diagram of public web pages flowing through a terracotta volume meter into a BI budget panel.
    The Line Item Behind Public Web Data in BI: Proxy Bandwidth
    12 Min Read
    Flat editorial illustration: The article is about joining public web signals with internal business metrics so BI teams can inter
    Alternative Data in BI: Bringing Public Web Data Into Your Dashboards
    23 Min Read
    Flat editorial illustration: The article is about automating the collection, preparation, and delivery of marketing data across p
    From Data to Dashboards: 5 Marketing Reporting Automation Software Picks
    12 Min Read
    Flat editorial illustration: The article contrasts passive follower totals with a behavioral path from attention and trust to cli
    Creator Analytics Beyond Follower Count: Seven Metrics That Measure Audience Behavior
    11 Min Read
    Flat editorial illustration: The article connects AI and marketing analytics with managerial judgment grounded in consumer behavi
    How an Online MBA in Marketing Connects AI and Data Analytics
    11 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
Geographic maps in R
Illustration generated with FLUX.2 [klein 4B] via Cloudflare Workers AI.
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

Notes from Tableau Roadshow: Every Picture Tells a (Data) Story
Notes from Tableau Roadshow: Every Picture Tells a (Data) Story
Seven Misconceptions about Data Quality
Forecast Product Demand with Confidence
The Information Supply Chain and the Growth of Enterprise App Stores
Big Data: Where the Opportunities Are!

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


    TAGGED:r language
    Share This Article
    Facebook Pinterest LinkedIn
    Share

    Follow us on Facebook

    Latest News

    Cut-paper editorial diagram of service callback tickets moving through a terracotta sorter into rising scorecard bars.
    Why Your Redo Jobs Hold the Best Data in Your Franchise
    Big Data Data Collection Exclusive
    Cut-paper editorial diagram of public web pages flowing through a terracotta volume meter into a BI budget panel.
    The Line Item Behind Public Web Data in BI: Proxy Bandwidth
    Big Data Business Intelligence Exclusive Web Analytics
    Cut-paper editorial diagram of raw business invoices moving through a terracotta data pipeline into structured analytics.
    Where Intelligent Automation & Data Pipelines Pay Off First
    Artificial Intelligence Big Data
    Layered cream, terracotta, and charcoal paper contract sheets flowing through a security shield into a verified server rack
    What Should a Managed IT Service Agreement Include?
    IT

    Stay Connected

    1.2KFollowersLike
    33.7KFollowersFollow
    222FollowersPin

    You Might also Like

    SnapLogic: Making Big Data Integration as a Service a Hadoop Reality
    Uncategorized

    SnapLogic: Making Big Data Integration as a Service a Hadoop Reality

    4 Min Read
    A Data Scientist Investigates the Belgian Municipal Elections
    Uncategorized

    A Data Scientist Investigates the Belgian Municipal Elections

    13 Min Read
    The First Data Scientist on the Evolution of Data Science
    AnalyticsBig DataHadoop

    The First Data Scientist on the Evolution of Data Science

    11 Min Read
    Microsoft and the Revolution: Analytics
    Uncategorized

    Microsoft and the Revolution: Analytics

    9 Min Read

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

    Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
    Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
    Artificial Intelligence Chatbots Exclusive
    The Art of Conversation: Enhancing Chatbots with Advanced AI Prompts
    The Art of Conversation: Enhancing Chatbots with Advanced AI Prompts
    Chatbots

    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?