Note that there are some explanatory texts on larger screens.

plurals
  1. POR: creating a map of selected Canadian provinces and U.S. states
    text
    copied!<p>I am attempting to create a map of selected Canadian provinces/territories and selected U.S. states. So far the nicest maps appear to be those generated with GADM data: <a href="http://www.gadm.org/" rel="nofollow noreferrer">http://www.gadm.org/</a> </p> <p>However, I have not been able to plot the U.S. and Canada on the same map or plot only selected provinces/territories and states. For example, I am interested in Alaska, Yukon, NWT, British Columbia, Alberta, and Montana among others.</p> <p>Also, the U.S. map appears to be split along the international dateline.</p> <p>Can someone please help me to:</p> <ol> <li>plot the aforementioned provinces/territories and states on a single map</li> <li>avoid having the U.S. split along the International dateline</li> <li>overlay a latitude-longitude grid</li> <li>select a specific projection, maybe the polyconic.</li> </ol> <p>Maybe spplot does not allow users to specify projections. I did not see an option to select a projection on the spplot help page. I know how to select projections with the map function in the maps package but those maps did not appear to look as nice and I could not plot the desired subset of provinces/territories and states with that function either.</p> <p>I do not know how to begin adding a latitude-longitude grid. However, Section 3.2 of the file 'sp.pdf' seems to address the topic.</p> <p>Below is the code I have come up with so far. I have loaded every map-related package I have stumbled upon and commented out GADM data except for provincial/territorial or state boundaries.</p> <p>Unfortunately, so far I have only managed to plot maps of Canada or the U.S.</p> <pre><code>library(maps) library(mapproj) library(mapdata) library(rgeos) library(maptools) library(sp) library(raster) library(rgdal) # can0&lt;-getData('GADM', country="CAN", level=0) # Canada can1&lt;-getData('GADM', country="CAN", level=1) # provinces # can2&lt;-getData('GADM', country="CAN", level=2) # counties plot(can1) spplot(can1, "NAME_1") # colors the provinces and provides # a color-coded legend for them can1$NAME_1 # returns names of provinces/territories # us0 &lt;- getData('GADM', country="USA", level=0) us1 &lt;- getData('GADM', country="USA", level=1) # us2 &lt;- getData('GADM', country="USA", level=2) plot(us1) # state boundaries split at # the dateline us1$NAME_1 # returns names of the states + DC spplot(us1, "ID_1") spplot(us1, "NAME_1") # color codes states and # provides their names # # Here attempting unsuccessfully to combine U.S. and Canada on one map. # Attempts at selecting given states or provinces have been unsuccessful. # plot(us1,can1) us.can1 &lt;- rbind(us1,can1) </code></pre> <p>Thanks for any help. So far I have made no progress with Steps 2 - 4 above. Perhaps I am asking for too much. Perhaps I should simply switch to ArcGIS and try that software.</p> <p>I have read this StackOverflow post:</p> <p><a href="https://stackoverflow.com/questions/5757058/can-r-be-used-for-gis">Can R be used for GIS?</a></p> <p>EDIT</p> <p>I have now borrowed an electronic copy of 'Applied Spatial Data Analysis with R' Bevand et al. (2008) and downloaded (or located) associated R code and data from the book's website:</p> <p><a href="http://www.asdar-book.org/" rel="nofollow noreferrer">http://www.asdar-book.org/</a></p> <p>I also found some nice-looking GIS-related R code here:</p> <p><a href="https://sites.google.com/site/rodriguezsanchezf/news/usingrasagis" rel="nofollow noreferrer">https://sites.google.com/site/rodriguezsanchezf/news/usingrasagis</a></p> <p>If and when I learn how to accomplish the desired objectives I will post solutions here. Although I may eventually move to ArcGIS if I cannot accomplish the objectives in R.</p>
 

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