[R] Coloring Canada provinces (package maps?)

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Thu Jan 26 17:03:43 CET 2012


Barry, thanks a lot!
I was able to read in Candian data set from gadm:

library(raster)
# Finding ISO3 code for Canada
getData('ISO3')  # Canada's code is "CAN"
# Reading in data at different levels
can0<-getData('GADM', country="CAN", level=0)
can1<-getData('GADM', country="CAN", level=1)
can2<-getData('GADM', country="CAN", level=2)
class(can0)
str(can0)
class(can1)
str(can1)

Apologies for a novice question (I've never worked with maps and
raster before): what is the way in raster to see what are the
geographic units within each data set (can0, can1, can2)?
And what function allows to plot them and color them?

Thanks a lot for the hints!
Dimitri



On Wed, Jan 25, 2012 at 4:37 PM, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
> On Wed, Jan 25, 2012 at 9:25 PM, Dimitri Liakhovitski
> <dimitri.liakhovitski at gmail.com> wrote:
>> Dear R'ers,
>>
>> I am wondering what is the smallest geographicterritorial unit
>> available for formatting in Canada. Provinces?
>>
>>
>> I know that in the US it is the county so that I can color US
>> counties any way I want, for example:
>>
>> ### Example for coloring US counties
>> ### Creating an ARTIFICIAL criterion for coloring US counties:
>> library(maps)
>
> If you want to extend your skills beyond the map package then you can
> plot anything that you can get a shapefile, or other common geospatial
> data set of, using the sp packages and friends such as maptools and
> rgdal.
>
>  gadm has four levels of Canadian boundaries, at first glance -
> country, province (black), something smaller than province (blue) and
> then red which looks like urban divisions.
>
>  The province upper-left doesn't seem to have any blue subdivisions,
> but that's possibly because there would be more subdivisions than
> people who actually live there.
>
> http://www.gadm.org/download
>
>  Gadm also has a facility to download the data as .Rdata objects that
> can load straight into R.
>
>  You might want to ask questions about spatial data programming on
> R-sig-geo or even on www.stackoverflow.com with the R tag.
>
> Barry



-- 
Dimitri Liakhovitski
marketfusionanalytics.com



More information about the R-help mailing list