Skip to content

Commit

Permalink
reknitting
Browse files Browse the repository at this point in the history
  • Loading branch information
cgettings committed Mar 28, 2024
1 parent e526479 commit b9cff84
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 50 deletions.
2 changes: 1 addition & 1 deletion code/2-choropleth.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ time_periods <-

# ==== get geo data ==== #

# The `topojson_read` function from `geojsonio` returns an `sf`-classed object with a `geometry` column. This is what leaflet is going to use to create the choropleth.
# The `read_sf` function from `sf` returns an `sf`-classed object with a `geometry` column. This is what leaflet is going to use to create the choropleth.

nta_2020 <- read_sf(paste0(base_url, "geography/NTA_2020.topo.json"), crs = 4326)

Expand Down
2 changes: 1 addition & 1 deletion code/2-choropleth.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ nta_2020 <- read_sf(paste0(base_url, "geography/NTA_2020.topo.json"), crs = 4326
```

The `topojson_read` function from `geojsonio` returns an `sf`-classed object with a `geometry` column. This is what leaflet is going to use to create the choropleth.
The `read_sf` function from `sf` returns an `sf`-classed object with a `geometry` column. This is what leaflet is going to use to create the choropleth.

## Join the data and metadata

Expand Down
2 changes: 1 addition & 1 deletion code/3-raster.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ nyccas_map <-
# zIndex = -1000 makes sure that the tiles are always the lowest layer
addProviderTiles(
# provider = providers$Stadia.AlidadeSmoothDark,
# provider = providers$Stadia.AlidadeSmoothDark,
# provider = providers$CartoDB.DarkMatter,
provider = providers$Jawg.Matrix,
options = providerTileOptions(zIndex = -1000, accessToken = jawg_token),
Expand Down
12 changes: 6 additions & 6 deletions docs/1-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -5800,14 +5800,14 @@ <h1>Very simple</h1>
<p>This is all you need to create a leaflet map:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" tabindex="-1"></a>useless_map <span class="ot">&lt;-</span> <span class="fu">leaflet</span>() <span class="sc">%&gt;%</span> <span class="fu">addTiles</span>()</span>
<span id="cb2-2"><a href="#cb2-2" tabindex="-1"></a>useless_map</span></code></pre></div>
<div class="leaflet html-widget html-fill-item" id="htmlwidget-881f9ac1007f7d1efddd" style="width:672px;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-881f9ac1007f7d1efddd">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]}]},"evals":[],"jsHooks":[]}</script>
<div class="leaflet html-widget html-fill-item" id="htmlwidget-cf686588074625e85059" style="width:672px;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-cf686588074625e85059">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]}]},"evals":[],"jsHooks":[]}</script>
<p>It’s not very useful, but it’s nice that it works out of the box.
Let’s set the initial view so we can see something:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a>sheep_meadow <span class="ot">&lt;-</span> useless_map <span class="sc">%&gt;%</span> <span class="fu">setView</span>(<span class="at">lng =</span> <span class="sc">-</span><span class="fl">73.975</span>, <span class="at">lat =</span> <span class="fl">40.772</span>, <span class="at">zoom =</span> <span class="dv">15</span>)</span>
<span id="cb3-2"><a href="#cb3-2" tabindex="-1"></a>sheep_meadow</span></code></pre></div>
<div class="leaflet html-widget html-fill-item" id="htmlwidget-8f819e420c29b8d20a2d" style="width:672px;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-8f819e420c29b8d20a2d">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]}],"setView":[[40.772,-73.975],15,[]]},"evals":[],"jsHooks":[]}</script>
<div class="leaflet html-widget html-fill-item" id="htmlwidget-cd35e874833167ae7bfb" style="width:672px;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-cd35e874833167ae7bfb">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]}],"setView":[[40.772,-73.975],15,[]]},"evals":[],"jsHooks":[]}</script>
<p>It still only has a tile layer. Let’s add a marker with a popup.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a>sheep_meadow_marker <span class="ot">&lt;-</span> </span>
<span id="cb4-2"><a href="#cb4-2" tabindex="-1"></a> sheep_meadow <span class="sc">%&gt;%</span> </span>
Expand All @@ -5819,8 +5819,8 @@ <h1>Very simple</h1>
<span id="cb4-8"><a href="#cb4-8" tabindex="-1"></a> )</span>
<span id="cb4-9"><a href="#cb4-9" tabindex="-1"></a></span>
<span id="cb4-10"><a href="#cb4-10" tabindex="-1"></a>sheep_meadow_marker</span></code></pre></div>
<div class="leaflet html-widget html-fill-item" id="htmlwidget-29d1748b672fe24c1eb7" style="width:672px;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-29d1748b672fe24c1eb7">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]},{"method":"addMarkers","args":[40.772,-73.975,null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},"It's a nice place to hang out",null,null,null,"This is the Sheep Meadow",{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]}],"setView":[[40.772,-73.975],15,[]],"limits":{"lat":[40.772,40.772],"lng":[-73.975,-73.975]}},"evals":[],"jsHooks":[]}</script>
<div class="leaflet html-widget html-fill-item" id="htmlwidget-7f2645bd5839834d3aef" style="width:672px;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-7f2645bd5839834d3aef">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]},{"method":"addMarkers","args":[40.772,-73.975,null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},"It's a nice place to hang out",null,null,null,"This is the Sheep Meadow",{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]}],"setView":[[40.772,-73.975],15,[]],"limits":{"lat":[40.772,40.772],"lng":[-73.975,-73.975]}},"evals":[],"jsHooks":[]}</script>
</div>
<div id="save-the-map" class="section level1">
<h1>Save the map</h1>
Expand Down
6 changes: 3 additions & 3 deletions docs/1-basic_map_non-self-contained.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
</head>
<body>
<div id="htmlwidget_container">
<div class="leaflet html-widget html-fill-item" id="htmlwidget-31154c3ab4da7b34506a" style="width:100%;height:400px;"></div>
<div class="leaflet html-widget html-fill-item" id="htmlwidget-dd9166cf57cdc38d1469" style="width:100%;height:400px;"></div>
</div>
<script type="application/json" data-for="htmlwidget-31154c3ab4da7b34506a">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]},{"method":"addMarkers","args":[40.772,-73.975,null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},"It's a nice place to hang out",null,null,null,"This is the Sheep Meadow",{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]}],"setView":[[40.772,-73.975],15,[]],"limits":{"lat":[40.772,40.772],"lng":[-73.975,-73.975]}},"evals":[],"jsHooks":[]}</script>
<script type="application/htmlwidget-sizing" data-for="htmlwidget-31154c3ab4da7b34506a">{"viewer":{"width":"100%","height":400,"padding":0,"fill":true},"browser":{"width":"100%","height":400,"padding":0,"fill":true}}</script>
<script type="application/json" data-for="htmlwidget-dd9166cf57cdc38d1469">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]},{"method":"addMarkers","args":[40.772,-73.975,null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},"It's a nice place to hang out",null,null,null,"This is the Sheep Meadow",{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]}],"setView":[[40.772,-73.975],15,[]],"limits":{"lat":[40.772,40.772],"lng":[-73.975,-73.975]}},"evals":[],"jsHooks":[]}</script>
<script type="application/htmlwidget-sizing" data-for="htmlwidget-dd9166cf57cdc38d1469">{"viewer":{"width":"100%","height":400,"padding":0,"fill":true},"browser":{"width":"100%","height":400,"padding":0,"fill":true}}</script>
</body>
</html>
6 changes: 3 additions & 3 deletions docs/1-basic_map_self-contained.html
Original file line number Diff line number Diff line change
Expand Up @@ -4053,9 +4053,9 @@
</head>
<body style="background-color: white;">
<div id="htmlwidget_container">
<div class="leaflet html-widget html-fill-item" id="htmlwidget-a8aa08d52f399c9ae7a2" style="width:100%;height:400px;"></div>
<div class="leaflet html-widget html-fill-item" id="htmlwidget-20bd54afac693e4b0902" style="width:100%;height:400px;"></div>
</div>
<script type="application/json" data-for="htmlwidget-a8aa08d52f399c9ae7a2">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]},{"method":"addMarkers","args":[40.772,-73.975,null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},"It's a nice place to hang out",null,null,null,"This is the Sheep Meadow",{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]}],"setView":[[40.772,-73.975],15,[]],"limits":{"lat":[40.772,40.772],"lng":[-73.975,-73.975]}},"evals":[],"jsHooks":[]}</script>
<script type="application/htmlwidget-sizing" data-for="htmlwidget-a8aa08d52f399c9ae7a2">{"viewer":{"width":"100%","height":400,"padding":0,"fill":true},"browser":{"width":"100%","height":400,"padding":0,"fill":true}}</script>
<script type="application/json" data-for="htmlwidget-20bd54afac693e4b0902">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"https://openstreetmap.org/copyright/\">OpenStreetMap<\/a>, <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL<\/a>"}]},{"method":"addMarkers","args":[40.772,-73.975,null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},"It's a nice place to hang out",null,null,null,"This is the Sheep Meadow",{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]}],"setView":[[40.772,-73.975],15,[]],"limits":{"lat":[40.772,40.772],"lng":[-73.975,-73.975]}},"evals":[],"jsHooks":[]}</script>
<script type="application/htmlwidget-sizing" data-for="htmlwidget-20bd54afac693e4b0902">{"viewer":{"width":"100%","height":400,"padding":0,"fill":true},"browser":{"width":"100%","height":400,"padding":0,"fill":true}}</script>
</body>
</html>
11 changes: 5 additions & 6 deletions docs/2-choropleth.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/2-choropleth_map_non-self-contained.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/2-choropleth_map_self-contained.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/3-raster.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/3-raster_map_non-self-contained.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/3-raster_map_self-contained.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/4-light-pollution_map_non-self-contained.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/4-light-pollution_map_self-contained.html

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions docs/4-light_pollution.html

Large diffs are not rendered by default.

0 comments on commit b9cff84

Please sign in to comment.