Skip to content

Commit bedd8ed

Browse files
committed
Update readme.md
1 parent 5fda134 commit bedd8ed

File tree

5 files changed

+155
-15
lines changed

5 files changed

+155
-15
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(download_geography)
4-
export(get_geoinfo)
4+
export(geoinfo)

R/utils.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ download_geography <- function(geo_path, geo_dir = NULL) {
6161
#'
6262
#' @examples
6363
#' \donttest{
64-
#' get_geoinfo("lpr_000a16a_e")
64+
#' geoinfo("lpr_000a16a_e")
6565
#' }
66-
get_geoinfo <- function(filename) {
66+
geoinfo <- function(filename) {
6767

6868
extract_codes <- canmap::code_pos
6969

@@ -88,7 +88,6 @@ get_geoinfo <- function(filename) {
8888

8989
dplyr::select(code_descriptions, .data$filename, .data$ref_date,
9090
.data$geo_code, .data$geo_level, .data$file_type,
91-
.data$format, .data$projection, .data$geo_coverage,
92-
.data$language)
91+
.data$format, .data$projection, .data$language)
9392

9493
}

README.Rmd

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,60 @@ library(canmap)
3636
tibble::as_tibble(shapefile_paths)
3737
3838
# then pick a shapefile and get the link:
39-
shapefile_paths[1, c("filepath", "path")]
39+
(url <- shapefile_paths[1, ]$path)
40+
41+
# then you can download it yourself, or use download_geography(url)
42+
```
43+
44+
45+
## Documentation
46+
47+
48+
A list of useful links to clean up later:
49+
50+
* [Geography definitions and documentation](https://www.statcan.gc.ca/eng/subjects/standard/sgc/geography)
51+
* [Root for geography downloads and documentation](https://www12.statcan.gc.ca/census-recensement/2016/geo/index-eng.cfm)
52+
* [Direct link to download directory for 2016 shapefiles](https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm)
53+
* [Heirarchy of geography](https://www150.statcan.gc.ca/n1/pub/92-195-x/2011001/other-autre/hierarch/h-eng.htm)
54+
55+
56+
### Parsing the filename for metadata
57+
58+
Suppose you've downloaded the geography file ```lpr_000a16a_e.zip```. The filename defines the important geographic characteristics of the file (you can process using the ```code_pos``` dataset for code positions, or ```get_geoinfo```).
59+
60+
```{r codes, warning = FALSE, message = FALSE}
61+
str(geoinfo("lpr_000a16a_e"))
62+
```
63+
64+
And each of these codes has a meaning that can be found (sometimes) in the geography guide that accompanies a downloaded file (but you can't find out the details until *after* you've downloaded it, and is missing some information).
65+
66+
Your first default parameters should be:
67+
68+
- ```file_type == "a"``` (digital boundary file---it doesn't look as good but it's smaller)
69+
- ```format == "a"``` (ArcGIS/ArcInfo®/.shp---for use with ```sf``` and other ```R``` geographic packages)
70+
- ```geo_coverage == "000"``` (Canada---the only option AFAIK)
71+
- ```projection == "g"``` (geographic projection/lat-long---this makes it less likely for the user to get caught up in coordinate reference systems [CRS] conversion issues)
72+
73+
The most important choices for the user are: year (2016 is the latest census year currently available), language (english or french) and geo_code/geo_level. A list of geo codes and geo levels are given in the ```code_book``` dataset:
74+
75+
``` {r geos}
76+
dplyr::filter(code_book, code_type == "geo_level")
77+
```
78+
79+
Business data usually isn't released below the economic region level (```er_```), while census data can go down to census tract (```ct_```), dissemination area (```da_```) or dissemination block (```db_```).
80+
81+
These are english codes, while the french codes are also in the dataset---english and french maps are in different files, so they have different codes: ```lpr_000a16a_e.zip``` has the english province/territory maps and ```lpr_000a16a_f.zip``` has the french province/territory maps. The only difference, AFAIK, is that the guide and geography names are in french in the french version.
82+
83+
84+
## Download and extract shapefiles to ```./geography/```
85+
86+
``` {r eval = FALSE}
87+
download_geography(url)
4088
```
4189

4290

91+
## Notes
92+
4393
Please note that the 'canmap' project is released with a
4494
[Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md).
4595
By contributing to this project, you agree to abide by its terms.

README.md

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,104 @@ tibble::as_tibble(shapefile_paths)
4141
#> # … with 24 more rows, and 1 more variable: language <chr>
4242

4343
# then pick a shapefile and get the link:
44-
shapefile_paths[1, c("filepath", "path")]
45-
#> # A tibble: 1 x 2
46-
#> filepath path
47-
#> <chr> <chr>
48-
#> 1 lada000b16a_e http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-li…
44+
(url <- shapefile_paths[1, ]$path)
45+
#> [1] "http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/2016/lada000b16a_e.zip"
46+
47+
# then you can download it yourself, or use download_geography(url)
48+
```
49+
50+
## Documentation
51+
52+
A list of useful links to clean up later:
53+
54+
- [Geography definitions and
55+
documentation](https://www.statcan.gc.ca/eng/subjects/standard/sgc/geography)
56+
- [Root for geography downloads and
57+
documentation](https://www12.statcan.gc.ca/census-recensement/2016/geo/index-eng.cfm)
58+
- [Direct link to download directory for 2016
59+
shapefiles](https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm)
60+
- [Heirarchy of
61+
geography](https://www150.statcan.gc.ca/n1/pub/92-195-x/2011001/other-autre/hierarch/h-eng.htm)
62+
63+
### Parsing the filename for metadata
64+
65+
Suppose you’ve downloaded the geography file `lpr_000a16a_e.zip`. The
66+
filename defines the important geographic characteristics of the file
67+
(you can process using the `code_pos` dataset for code positions, or
68+
`get_geoinfo`).
69+
70+
``` r
71+
str(get_geoinfo("lpr_000a16a_e"))
72+
#> Classes 'tbl_df', 'tbl' and 'data.frame': 1 obs. of 9 variables:
73+
#> $ filename : chr "lpr_000a16a_e"
74+
#> $ ref_date : chr "2016"
75+
#> $ geo_code : chr "pr_"
76+
#> $ geo_level : chr "province and territory"
77+
#> $ file_type : chr "digital boundary file"
78+
#> $ format : chr "ArcGIS (.shp)"
79+
#> $ projection : chr "projection in Lambert conformal conic"
80+
#> $ geo_coverage: chr "canada"
81+
#> $ language : chr "english"
4982
```
5083

84+
And each of these codes has a meaning that can be found (sometimes) in
85+
the geography guide that accompanies a downloaded file (but you can’t
86+
find out the details until *after* you’ve downloaded it, and is missing
87+
some information).
88+
89+
Your first default parameters should be:
90+
91+
- `file_type == "a"` (digital boundary file—it doesn’t look as good
92+
but it’s smaller)
93+
- `format == "a"` (ArcGIS/ArcInfo®/.shp—for use with `sf` and other
94+
`R` geographic packages)
95+
- `geo_coverage == "000"` (Canada—the only option AFAIK)
96+
- `projection == "g"` (geographic projection/lat-long—this makes it
97+
less likely for the user to get caught up in coordinate reference
98+
systems \[CRS\] conversion issues)
99+
100+
The most important choices for the user are: year (2016 is the latest
101+
census year currently available), language (english or french) and
102+
geo\_code/geo\_level. A list of geo codes and geo levels are given in
103+
the `code_book` dataset:
104+
105+
``` r
106+
dplyr::filter(code_book, code_type == "geo_level")
107+
#> # A tibble: 34 x 3
108+
#> code_type code code_desc
109+
#> <chr> <chr> <chr>
110+
#> 1 geo_level pr_ province and territory
111+
#> 2 geo_level cd_ census division
112+
#> 3 geo_level ccs census consolidated subdivision
113+
#> 4 geo_level csd census subdivision
114+
#> 5 geo_level er_ economic region
115+
#> 6 geo_level cma census metropolitan area and census agglomeration
116+
#> 7 geo_level fed federal electoral district
117+
#> 8 geo_level ct_ census tract
118+
#> 9 geo_level dpl designated place
119+
#> 10 geo_level pc_ population centre
120+
#> # … with 24 more rows
121+
```
122+
123+
Business data usually isn’t released below the economic region level
124+
(`er_`), while census data can go down to census tract (`ct_`),
125+
dissemination area (`da_`) or dissemination block (`db_`).
126+
127+
These are english codes, while the french codes are also in the
128+
dataset—english and french maps are in different files, so they have
129+
different codes: `lpr_000a16a_e.zip` has the english province/territory
130+
maps and `lpr_000a16a_f.zip` has the french province/territory maps. The
131+
only difference, AFAIK, is that the guide and geography names are in
132+
french in the french version.
133+
134+
## Download and extract shapefiles to `./geography/`
135+
136+
``` r
137+
download_geography("lpr_000a16a_e")
138+
```
139+
140+
## Notes
141+
51142
Please note that the ‘canmap’ project is released with a [Contributor
52143
Code of Conduct](.github/CODE_OF_CONDUCT.md). By contributing to this
53144
project, you agree to abide by its terms.
Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)