Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you are using geographical data, maybe the <code>raster</code> package is useful for you. For example, let's display the altitude of France (download this <a href="http://diva-gis.org/data/alt/FRA_alt.zip" rel="nofollow"><code>zip</code></a> file or use the <code>raster::getData</code> function). After you <code>unzip</code> the file:</p> <pre><code>library(raster) fraAlt &lt;- raster('FRA_alt') plot(fraAlt) ## Not only France is displayed... </code></pre> <p>If you want to display only the altitude of France, you need the information of the boundaries: download this <a href="http://gadm.org/data/rda/FRA_adm0.RData" rel="nofollow"><code>RData</code></a> file (or use the <code>raster::getData</code> function). This <code>RData</code> contains a <code>SpatialPolygonsDataFrame</code> (named <code>gadm</code>) which can be converted to a <code>Raster</code> with:</p> <pre><code> mk &lt;- rasterize(gadm, fraAlt) </code></pre> <p>Now you can mask the altitude raster with the boundaries:</p> <pre><code> fraAltMask &lt;- mask(fraAlt, x) plot(fraAltMask) ##Now only France is displayed </code></pre> <p>Finally, if you want to use <code>lattice</code> methods you need the <code>rasterVis</code> package:</p> <pre><code> library(rasterVis) levelplot(fraAlt) levelplot(fraAltMask) </code></pre> <p>Now, all together with the boundaries superimposed:</p> <pre><code> s &lt;- stack(fraAlt, fraAltMask) layerNames(s) &lt;- c('Alt', 'AltMask') boundaries &lt;- as(gadm, 'SpatialLines') levelplot(s) + layer(sp.lines(boundaries)) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload