Map

Column

Envision Cambridge Feedback Locations

About


About this map

The Envision Cambridge Street Team collected this data using the project’s Mobile Engagement Station. The Street Team asked participants at various locations across the City and throughout 2016 to mark a large map of Cambridge with their favorite and least favorite places in the city, and where they would like to see future change. More information and the data available here.

Visualization Copyright 2017 Kent S Johnson Creative Commons License 2017-02-28

---
title: "Envision Cambridge Mobile Engagement Feedback"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
    theme: spacelab
---

```{r setup, include=FALSE}
library(flexdashboard)
```

Map
============

```{r parameters, echo=FALSE,include=FALSE,message=FALSE}
library(tidyverse)
library(htmltools)
library(leaflet)
library(sp)

knitr::opts_chunk$set(echo=FALSE, results='asis',
                      comment=NA, warning=FALSE, message=FALSE)
```


```{r}
# Read City boundary
city = raster::shapefile('../BOUNDARY_CityBoundary.shp/BOUNDARY_CityBoundary.shp') %>% 
  spTransform(CRS("+init=EPSG:4326"))

# Read Envision data
fb <- read_csv("../Envision_Cambridge_Mobile_Engagement_Feedback.csv") %>% 
  rename(lat=`Latitude of Topic`, long=`Longitude of Topic`)

# Make popups
maybe = function(item, head=NULL, brk=TRUE)
  if(is.null(item) || is.na(item) || (is.numeric(item) && item==0)) '' else tagList((if(brk) br()), head, item)

make_popups = function(d)
  lapply(1:nrow(d),
       function(i) {
         row = d[i,]
         HTML(as.character(p(
           row$Type,
           maybe(row$Tag),
           maybe(row$Comment)
         )))
         })

popups = make_popups(fb)

# Function to assign colors to dots
color_fun = colorFactor(c('green', 'blue', 'red'), unique(fb$Type))

```

Column {data-width=1000}
-----------------------------------------------------------------------

### Envision Cambridge Feedback Locations

```{r}
# Make a map
map = leaflet() %>% addProviderTiles('Esri.WorldTopoMap') %>% 
  setView(-71.1129096, 42.3783904, zoom = 14) %>% 
  addPolygons(data=city, fill=FALSE, color='steelblue', weight=3)

map %>% addCircleMarkers(data=fb, color=~color_fun(Type),
                         radius=5, stroke=FALSE, opacity=0.6, fillOpacity=0.6,
            label=popups, group=~Type) %>% 
  addLayersControl(overlayGroups=sort(unique(fb$Type)))

```


About
================

---------------

### About this map

The Envision Cambridge Street Team collected this data using the project’s Mobile Engagement Station. The Street Team asked participants at various locations across the City and throughout 2016 to mark a large map of Cambridge with their favorite and least favorite places in the city, and where they would like to see future change. More information and the data available
[here](https://data.cambridgema.gov/Planning/Envision-Cambridge-Mobile-Engagement-Feedback/sx7w-cut7).

Visualization Copyright 2017 Kent S Johnson

  Creative Commons License
  `r Sys.Date()`