background preloader

Maps/GIS - Demographics

Facebook Twitter

Subplots in maps with ggplot2. Following the surprising success of my latest post, I decided to show yet another use case of the handy ggplot2::annotation_custom().

Subplots in maps with ggplot2

Here I will show how to add small graphical information to maps – just like putting a stamp on an envelope. The example comes from my current work on a paper, in which I study the effect of urban/rural differences on the relative differences in population ageing (I plan to tell a bit more in one of the next posts). Let’s have a look at the map we are going to reproduce in this post: So, with this map I want to show the location of more and less urbanized NUTS-2 regions of Europe. But I also want to show – with subplots – how I defined the three subregions of Europe (Eastern, Southern, and Western) and what is the relative frequency of the three categories of regions (Predominantly Rural, Intermediate, and Predominantly Rural) within each of the subregions. The code to prepare R session and load the data. Okay, now the envelope is ready.

Done! An Introduction to Spatial Data Analysis and Visualisation in R - CDRC Data. Where Europe lives, in 14 lines of R Code. Using R as a GIS. In real estate, spatial data is the name of the game.

Using R as a GIS

Countless programs in other domains utilize the power of this data, which is becoming more prevalent by the day. In this post I will go over a few simple, but powerful tools to get you started using using geographic information in R. GISTools provides an easy-to-use method for creating shading schemes and choropleth maps. Some of you may have heard of the sp package, which adds numerous spatial classes to the mix. There are also functions for analysis and making things look nice. Let’s get rolling: source the vulgaris dataset, which contains location information for Syringa Vulgaris (the Lilac) observation stations and US states.

One thing to note here is the structure of these objects. us_states is a SpatialPolygonsDataFrame, which stores information for plotting shapes (like a shapefile) within its attributes. vulgaris by contrast is a SpatialPointsDataFrame, which contains data for plotting individual points. Look familiar? Kiefer. Easy earthquake mapping using ggmap. Maps are great - German Gas Prices illustrated – Florian Teschner – YaDS (Yet another Data Scientist) One of the most appealing data visualisation charts are maps.

Maps are great - German Gas Prices illustrated – Florian Teschner – YaDS (Yet another Data Scientist)

I love maps as they combine an incredible information density with intuitive readability. Also I feel that most people prefer maps over other visualisations. (Is there research on this?) The rOpenSci geospatial suite. Geospatial data - data embedded in a spatial context - is used across disciplines, whether it be history, biology, business, tech, public health, etc.

The rOpenSci geospatial suite

Along with community contributors, we're working on a suite of tools to make working with spatial data in R as easy as possible. If you're not familiar with geospatial tools, it's helpful to see what people do with them in the real world. Example 1 One of our geospatial packages, geonames, is used for geocoding, the practice of either sorting out place names from geographic data, or vice versa. geonames interfaces with the open database of the same name: A recent paper in PlosONE highlights a common use case.

Mapping tweets: How to create your own web app. May 28, 2016 One of the reasons why Twitter has become so popular is because it is a great way to get data for web applications and projects.

Mapping tweets: How to create your own web app

Through its Search API, it is possible to find content by issuing a query to Twitter based on a supplied string. The results can then be parsed or displayed as preferred using ancillary tools. The purpose of this tutorial is that you learn how to create an interactive web app that retrieves geolocated tweets and shows them in a map. Sounds cool? Get access to Twitter API To get started, create a Twitter account. Notice that there are some rate limits for the Twitter Search API that you should take into account. Prepare the code for your app. Web mapping with Leaflet and R. Aug 11, 2015 Leaflet is a JavaScript library that has become quite popular for creating interactive maps.

Web mapping with Leaflet and R

One way to create a map using the Leaflet JS library is to include the Leaflet JS and CSS files in the head of a web page and then set up the map in the body of the html page, as shown in the Leaflet Quick Start Guide. Web mapping with Leaflet and R. R and GIS – working with shapefiles. Incase you missed it: My Webinar on Spatial Data Analysis with R. In case you missed my free webinar on “Getting Started with Spatial Data Analysis with R“, here is the recording.

Incase you missed it: My Webinar on Spatial Data Analysis with R

You can access the material used for this webinar from Domino Data Lab‘s platform using the following links: The Slides [domino-presentation.pdf]The RMarkdown Script [ReadMe.Rmd]The Whole Project [All files including data] If you have any questions, please do not hesitate to contact me. If you have more topics (related to R) that you are interested in learning about, send them my way so we can prepare another webinar. Finally, I would like to thank Anna Anisin from Domino Data Lab for setting up this webinar.

Upload shapefile to R Shiny app to extract leaflet map data. In this post I share an R Shiny app which uses the leaftlet package for interactive maps.

Upload shapefile to R Shiny app to extract leaflet map data

This app differs from prior apps I’ve made featuring leaflet maps. First, it displays rasterized map data rather than just point layers. Also, longitude and latitude sliders in the browser allow for cropping the map. Additionally, the user can upload a shapefile to crop and mask the rasterized data overlays in the leaflet window to the specific spatial data they wish to work with, and then extract and download that data. Japans ageing population, animated with R. The US Census makes a number of its databases available to developers via the Census API.

Japans ageing population, animated with R

One of those databases is the International Data Base, in which the Census department provides historic demographic breakdowns (population by age and sex) for many countries, along with projections through 2050. Kyle Walker created the R package idbr (currently only available on GitHub) to make it easy to download these datasets using R, and used it to create the animation below showing Japan's demographic change since 1990. As you can see, the Census Bureau predicts that this ageing of the population will only intensify over time. Note the ever-declining population of babies being added at the bottom of the chart. In fact, Japan's population declined for the first time just this year.

Kyle used ggplot's geom_bar plot to visulize the population pyramid, and rendered it using the Economist theme from the ggthemes package. For more on Kyle's idbr package, check out the GitHub repository linked below. Tips for reading spatial files into R with rgdal. R has become a go-to tool for spatial analysis in many settings.

Tips for reading spatial files into R with rgdal

You can read and edit spatial data, conduct geoprocessing and spatial analysis and create static and interactive maps. Visualising your hiking trails and photos with My Tracks, R and Leaflet. 18 November 2015 After a hiking vacation, it is nice to have some sort of visual record afterwards. While there are likely professionaly solutions to record and visualise your trails, as a recreational hiker you can already get a lot of milage from your smartphone in combination with the R data-analysis ecosystem. A few weeks ago, we used the Android app My Tracks to record our hikes in Italy. It is a very basic, straightforward app: hit record, let it run while you walk around, and hit stop at the end.

In the meantime it provides statistics & graphs on speed, elevation, etc. Building Interactive Maps with Leaflet. Leaflet is an JavaScript library for building interactive maps. RStudio released a package that allows us to build these maps in R! You can do some really cool things in Leaflet, and I will demonstrate a few of those below. Manipulating and mapping US Census data in R using the acs, tigris and leaflet packages. The US Census provides an incredible wealth of data but it’s not always easy to work with it. In the past, working with the tabular and spatial census data generally meant downloading a table from FactFinder and a shapefile from the boundary files site and joining the two, perhaps in a GIS system. Technical Tidbits From Spatial Analysis & Data Science.

Display of Geographic Data in R – Adventures in Analytics and Visualization. MapView: basic interactive viewing of spatial data in R. Administrative Maps and Projections in R - AriLamstein.com. Thematic Mapping in R without the Tears, Walkthrough. Geographic visualization with R's ggmap. Have you ever crunched some numbers on data that involved spatial locations? If the answer is no, then boy are you missing out! So much spatial data to analyze and so little time. Since your time is precious, you know that attempting to create spatial plots in languages like Matlab or applications like Excel can be a tedious, long process. R tutorial for Spatial Statistics: Organize a walk around London with R. Mortgages Are About Math: Open-Source Loan-Level Analysis of Fannie and Freddie - Todd W. Schneider.

[M]ortgages were acknowledged to be the most mathematically complex securities in the marketplace. R Video tutorial for Spatial Statistics: Interactive maps for the web in R. Choroplethr v3.1.0: Better Summary Demographic Data. Today I am happy to announce that choroplethr v3.1.0 is now on CRAN. Visualisation with R and Google Maps. Details. Zevross. Interactive Maps for John Snow’s Cholera Data. This week, in Istanbul, for the second training on data science, we’ve been discussing classification and regression models, but also visualisation. Including maps. And we did have a brief introduction to the leaflet package, Amphitheaters. Roman Amphitheater in-Class "Mash Up" Mapping Paris bikes stands - SHARP SIGHT LABS. Robin Lovelace - The leaflet package for online mapping in R. Spatial data in R: Using R as a GIS.

Robinlovelace/Creating-maps-in-R · GitHub. Spatial visualization with R. Robin Lovelace - Basic mapping and attribute joins in R. Ramnathv/rMaps. Technical Tidbits From Spatial Analysis & Data Science. » Proficiency levels @ PISA and visualisation challenge @ useR!2014 SmarterPoland. Creating Inset Map with ggplot2. Using R — Working with Geospatial Data (and ggplot2) The choroplethr package for R. Visualizing a tiny slice of India's demographics with information from Wikipedia. Ggplot2 Chloropleth of Supreme Court Decisions: A Tutorial.

The OpenStreetMap Package Opens Up « Fells Stats. Using R — Working with Geospatial Data. Create maps with maptools R package.