_BOUNDARY/DRP_COUNTY_BOUNDARY.shp&quot;</span>)</span></code></pre></div>
<pre><code>## Reading layer `DRP_COUNTY_BOUNDARY&#39; from data source `/Users/timdennis/instruction/afam188/afam188-r/data/DRP_COUNTY_BOUNDARY/DRP_COUNTY_BOUNDARY.shp&#39; using driver `ESRI Shapefile&#39;
## Simple feature collection with 2 features and 2 fields
## geometry type:  MULTILINESTRING
## dimension:      XY
## bbox:           xmin: 6280000 ymin: 1380000 xmax: 6670000 ymax: 2120000
## epsg (SRID):    2229
## proj4string:    +proj=lcc +lat_1=35.46666666666667 +lat_2=34.03333333333333 +lat_0=33.5 +lon_0=-118 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs</code></pre>
<div class="sourceCode" id="cb63"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb63-1"><a href="mapping-in-r-tmaps-continued.html#cb63-1"></a><span class="co">#geometry type:  MULTIPOLYGON</span></span>
<span id="cb63-2"><a href="mapping-in-r-tmaps-continued.html#cb63-2"></a>la_zips &lt;-<span class="st"> </span><span class="kw">st_read</span>(<span class="dt">dsn =</span> <span class="st">&quot;data/Los_Angeles_City_Zip_Codes/Los_Angeles_City_Zip_Codes.shp&quot;</span>)</span></code></pre></div>
<pre><code>## Reading layer `Los_Angeles_City_Zip_Codes&#39; from data source `/Users/timdennis/instruction/afam188/afam188-r/data/Los_Angeles_City_Zip_Codes/Los_Angeles_City_Zip_Codes.shp&#39; using driver `ESRI Shapefile&#39;
## Simple feature collection with 157 features and 7 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -119 ymin: 33.7 xmax: -118 ymax: 34.3
## epsg (SRID):    4326
## proj4string:    +proj=longlat +datum=WGS84 +no_defs</code></pre>
<div class="sourceCode" id="cb65"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb65-1"><a href="mapping-in-r-tmaps-continued.html#cb65-1"></a><span class="co">#geometry type:  MULTILINESTRING</span></span>
<span id="cb65-2"><a href="mapping-in-r-tmaps-continued.html#cb65-2"></a>la_freeways &lt;-<span class="st"> </span><span class="kw">st_read</span>(<span class="dt">dsn =</span><span class="st">&quot;data/CAMS_FREEWAY_SHIELDS/CAMS_FREEWAY_SHIELDS.shp&quot;</span>)</span></code></pre></div>
<pre><code>## Reading layer `CAMS_FREEWAY_SHIELDS&#39; from data source `/Users/timdennis/instruction/afam188/afam188-r/data/CAMS_FREEWAY_SHIELDS/CAMS_FREEWAY_SHIELDS.shp&#39; using driver `ESRI Shapefile&#39;
## Simple feature collection with 45 features and 4 fields
## geometry type:  MULTILINESTRING
## dimension:      XY
## bbox:           xmin: 6280000 ymin: 1720000 xmax: 6670000 ymax: 2120000
## epsg (SRID):    2229
## proj4string:    +proj=lcc +lat_1=35.46666666666667 +lat_2=34.03333333333333 +lat_0=33.5 +lon_0=-118 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs</code></pre>
<p>Now let’s use the layers. The important thing is we match our shapefile with the geometry type. <code>tm_polygons()</code> goes with <code>#geometry type:  MULTIPOLYGON</code> and <code>tm_line()</code> goes with <code>#geometry type:  MULTILINESTRING</code>. Let’s use this new knowledge to make the map better.</p>
<pre><code>## tmap mode set to plotting</code></pre>
<div class="sourceCode" id="cb68"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb68-1"><a href="mapping-in-r-tmaps-continued.html#cb68-1"></a><span class="kw">tm_shape</span>(la_zips) <span class="op">+</span></span>
<span id="cb68-2"><a href="mapping-in-r-tmaps-continued.html#cb68-2"></a><span class="st">  </span><span class="kw">tm_polygons</span>() <span class="op">+</span></span>
<span id="cb68-3"><a href="mapping-in-r-tmaps-continued.html#cb68-3"></a><span class="kw">tm_shape</span>(la_freeways) <span class="op">+</span></span>
<span id="cb68-4"><a href="mapping-in-r-tmaps-continued.html#cb68-4"></a><span class="st">  </span><span class="kw">tm_lines</span>() <span class="op">+</span></span>
<span id="cb68-5"><a href="mapping-in-r-tmaps-continued.html#cb68-5"></a><span class="kw">tm_shape</span>(arrests_sf) <span class="op">+</span></span>
<span id="cb68-6"><a href="mapping-in-r-tmaps-continued.html#cb68-6"></a><span class="st">  </span><span class="kw">tm_dots</span>() </span></code></pre></div>
<p><img src="afam-188r_files/figure-html/unnamed-chunk-20-1.png" width="\textwidth" style="display: block; margin: auto;" /></p>
<p>Ok, that’s more like it. Last thing before we break. So far, we’ve been using <code>tmap</code> to produce a static map, but <code>tmap</code> lets us create interactive maps by switching it’s mode to `view’. We can do this using a single line.</p>
<pre><code>## tmap mode set to interactive viewing</code></pre>
<div class="sourceCode" id="cb70"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb70-1"><a href="mapping-in-r-tmaps-continued.html#cb70-1"></a><span class="kw">tm_shape</span>(la_zips) <span class="op">+</span></span>
<span id="cb70-2"><a href="mapping-in-r-tmaps-continued.html#cb70-2"></a><span class="st">  </span><span class="kw">tm_polygons</span>() <span class="op">+</span></span>
<span id="cb70-3"><a href="mapping-in-r-tmaps-continued.html#cb70-3"></a><span class="kw">tm_shape</span>(la_freeways) <span class="op">+</span></span>
<span id="cb70-4"><a href="mapping-in-r-tmaps-continued.html#cb70-4