Leaflet maps in R Gene Leynes

Slides:



Advertisements
Similar presentations
Get Started with GIS Mapping Part 2 of 3 Madhu Lakshmanan.
Advertisements

Possible Windows 8 Improvements By: Scott Hill. Improve Windows 8 Split Screen Mode The only options for split screen mode currently is to have one screen.
The Simple Guide To More Complex Writing by John Frank
Annotation & Nomenclature By Corey Fortezzo for PG&G GIS Workshop, 2010.
Census Geography: Maps & Apps Joe Germuska NewsApps Developer Chicago Tribune 0:00.
19 th Advanced Summer School in Regional Science Overview and more advanced directions with ArcGIS.
Basics of thematic mapping in GIS (ArcMap) Kelly Clonts Presentation for UC Berkeley, D-Lab October 29 th, 2014.
Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their.
Parcel Data Models for the Geodatabase
GIS 1 GIS Lecture 4 Geodatabases. GIS 2 Outline Administrative Data Example Data Tables Data Joins Common Datasets Spatial Joins ArcCatalog Geodatabases.
Unit 1 – Improving Productivity Instructions ~ 100 words per box.
An Introduction to The Network for a Healthy California GIS Viewer Welcome to Webinar Anthony Barnes Bhavdeep Sachdev 9:00am to 10:30am.
Preparing and Deploying Data to ArcPad Juan Luera.
GIS 1 GIS Lecture 4 Geodatabases Copyright – Kristen S. Kurland, Carnegie Mellon University.
Displaying the results of an XPS Depth Profile Laura Blair.
Mr Barton’s Maths Notes Graphs 2. Quadratics and Cubics
CE 525 1/17/2013. Who’s here? Acceptable responses: Here Present Yep Yes sir!
1 Module 1 Highlights Learning your way around. 2 Course Stuff… There are now 45 of you! So I have to change some things 1.Each week when you hand in.
Using the AccuGlobe Software with the IndianaMap Using the AccuGlobe Software.
Midterm Activities: Due by Friday Process Journals must be in YOUR words Track 2 First finish Tutorial 2, then complete and print process journals for:
1 Data Dissemination Customer Liaison and Marketing Services Office (CLMSO) Web Adams, GISP Data Dissemination Specialist U.S. Census Bureau New York Regional.
Types of Spatial Data Sites Data portals: Find and download data –Humboldt County, National Atlas “Atlases”: General information –GoogleMaps, MapQuest.
Mapdraw ats315. Today’s goal: Drawing a map in the graphics window! Drawing a map in the graphics window!
This was written with the assumption that workbooks would be added. Even if these are not introduced until later, the same basic ideas apply Hopefully.
Acquiring socio-economic and business data for neighborhood analysis Open a web browser and go to: Barbara Parmenter Dept.
The Scientific Method.
AP CSP: Cleaning Data & Creating Summary Tables
Shiny for RStudio Exploring Web Mapping Technology
How to open source your Puppet configuration
Automated WFLOW-RIBASIM build
GIS using R A few examples Jaya Krishnan GIS Consultant
Authors of your poser here
Graphs 2. Quadratics and Cubics
Hazards Planning and Risk Management INTRODUCTION TO ARCGIS
Attribute Extraction.
Discord Bot Senior Project
Maps 1 EPID 799C Fall 2017.
ECONOMETRICS ii – spring 2018
Preliminaries: -- vector, raster, shapefiles, feature classes.
David R. Maidment GIS in Water Resources Fall 2018
Using Census data to find emerging immigrant communities in your area
File Handling Programming Guides.
Mr Barton’s Maths Notes
GIS Lecture: Data.
Working Spatial Data File Geodatabase
Web Maps with Leaflet GEOG 319/658 November 24, 2014.
Maps 1 EPID 799C Fall 2018.
Types of Spatial Data Sites
Authors of your poser here
The process behind making a good thematic map
Learn R! GIS.
Mapping Child Care Availability in Denver Ann Wacker
Learning Common GIS Workflows
What is it and how do you build one?
GIS Lecture: Data.
Mr Barton’s Maths Notes
Types of Spatial Data Sites
How to Format Your Lab Reports and Book
The process behind making a good thematic map
Types of Spatial Data Sites
Mapping a network drive
MPA-140: Slope Remember, slope is all about a line and how steep it is, and lines grow or shrink in TWO dimensions, with x’s and y’s we can plot on a graph.
Geographic Analysis Tools
Mr Barton’s Maths Notes
MIS2502: Data Analytics Introduction to Advanced Analytics and R
Executive Admin Assistant
Coding to Create 100+ Visualizations with the click of a button
Self-Regulation Strategies
Executive Admin Assistant
Two Geospatial Data Your Library that You Need to Know
Presentation transcript:

Leaflet maps in R Gene Leynes R Meetup Saturday 2017-10-14

Outline for today This is more or less a guided tour of my map repository, which is something I put together for myself when I need to make a map. https://github.com/geneorama/wnv_map_demo Main topics for today Data acquisition Working with shape files Basic leaflet map making Making a heat map Making a leaflet app

Data acquisition Thanks to the wonderful people who wrote the tigris and acs packages, it’s a lot easier to get census tract maps and census tract data You can use tigris to find the appropriate state and county codes, and download census map data Source: choropleth/leaflet_example.R

The Shapefile Plotting the shapefile doesn’t give you much, but you can see the data’s there Source: choropleth/leaflet_example.R

Shapefile What’s in the shape file? Data Polygons (the actual shapes) Metadata Source: choropleth/leaflet_example.R

Shapefile What’s in the polygons slot? An object called “Polygon” The most important component is “coords” which contains the actual points that defines the polygon I don’t know why it’s necessary to have this second nested level… maybe it’s not necessary. Metadata, the ID, area, a point for labels, etc

Shapefile data The @data slot is where the magic happens… If you want to assign attributes (say average income per census tract) to the polygons, you do it here

Getting income data Thanks to the authors of the acs package, getting American Community Survey data is a lot easier (but still not easy because you need to find the right variable names yourself) After some fussing… you can join the income data to the shapefile using the geo_join and merge on GEOID You can also use base R merge, but you have to be careful

The Leaflet Plot The actual leaflet plot: choropleth/leaflet_example.R

State Plane? FYI: Coordinate conversion functions are sometimes helpful… I have a couple of converters in the ./functions directory

Leaflet Tiles Within leaflet you can choose a myriad of backgrounds, or create your own Choose a background: https://leaflet-extras.github.io/leaflet-providers/preview/ Create a background: https://www.mapbox.com/

Custom Mapbox Template Tile Examples wnv_trap_map/20_Map_dev_v1.R (No background) Custom Mapbox Template (see code) m %>% addProviderTiles("CartoDB.Positron")

Awesome Tile Example m %>% addProviderTiles("Thunderforest.SpinalMap")

Layering Components wnv_trap_map\map_demo.Rmd

Advanced Examples In the repo there are some examples How to create heat maps that show point densities that don’t change with the zoom level Putting leaflet into a basic application

Putting leaflet into shiny Automating the map: Add controls to select different season years and collection periods .\app\app.R

Method 1: KDE heatmap\mv_thefts.R

Method 1: KDE Outline of process for creating KDE map: Acquire point data Calculate a KDE using the MASS function bkde2D (only tricky part is choosing bandwidth, which is all trial and error) Calculate contour lines based on KDE using contourLines Convert the list of contour lines into a shape file… This part is looks magical, but is really just calls to sp::Polygon sp::Polygons sp::SpatialPolygons heatmap\mv_thefts.R

Method 2: GAM Start off with a nice simple plot of the positive / negative traps and an outline of the city (created with gUnaryUnion) wnv_trap_map\20_Map_dev_v2_GAM.R

Method 2: GAM Outline of process for creating GAM map: Use base pos/neg data to calculate a GAM model Create a prediction grid that spans the entire city Predict on each point in the grid Calculate the average prediction value for each census tract Attach the color of the prediction to the shape file wnv_trap_map\20_Map_dev_v2_GAM.R

Method 2: GAM This is what the underlying prediction grid looks like wnv_trap_map\20_Map_dev_v2_GAM.R