geofacet icon indicating copy to clipboard operation
geofacet copied to clipboard

ch_vaud_districts

Open mick-weber opened this issue 4 years ago • 5 comments

List of districts for the Canton de Vaud, one of the 26 cantons of Switzerland. There are 10 Districts since a fusion in 2008.

Grid data:

name,code,row,col
Broye-Vully,2222,1,4
Jura-Nord vaudois,2224,1,2
Lausanne,2225,2,3
Riviera-Pays-d'Enhaut,2230,2,5
Lavaux-Oron,2226,2,4
Ouest lausannois,2229,2,2
Morges,2227,2,1
Gros-de-Vaud,2223,1,3
Aigle,2221,3,5
Nyon,2228,3,1

map

mick-weber avatar Jun 17 '21 13:06 mick-weber

stedy avatar Jun 18 '21 00:06 stedy

Do you have any idea when this can be added to {geofacet} ? It's quite urgent for my work 👍

Many thanks !

mick-weber avatar Jul 29 '21 15:07 mick-weber

It will be merged in with the package on the next release. I hope to do this soon.

In the mean time, since you created it, you can use the grid locally by passing the grid data frame you created to facet_geo. The grid submission is simply a service to the community so that others can use the grids as well.

Let me know if you have any issues using your grid.

hafen avatar Jul 31 '21 01:07 hafen

Thanks for the precision, I wasn't sure how to use it locally. Could you please specify how to pass the grid (from copy/pasting above) as an argument for facet_geo(grid = ...) ? Many thanks for your help !

mick-weber avatar Aug 01 '21 10:08 mick-weber

First, it looks like your grid needs some updates to conform with the package. It must have columns "name" and "code". Here's an update of the grid (you can probably come up with better codes than what I did).

name,code,row,col
Broye-Vully,br,1,4
Jura-Nord vaudois,ju,1,2
Lausanne,la,2,3
Riviera-Pays-d'Enhaut,ri,2,5
Lavaux-Oron,lv,2,4
Ouest lausannois,ol,2,2
Morges,mo,2,1
Gros-de-Vaud,gr,1,3
Aigle,ai,3,5
Nyon,ny,3,1

To use it in R, you need to get it into the form of a data frame. There's many ways to do this but here's one:

grd <- read.csv(textConnection("name,code,row,col
Broye-Vully,br,1,4
Jura-Nord vaudois,ju,1,2
Lausanne,la,2,3
Riviera-Pays-d'Enhaut,ri,2,5
Lavaux-Oron,lv,2,4
Ouest lausannois,ol,2,2
Morges,mo,2,1
Gros-de-Vaud,gr,1,3
Aigle,ai,3,5
Nyon,ny,3,1"))

library(geofacet)

# preview the grid
geofacet::grid_preview(grd)

# use in a plot (fill in the blanks)
ggplot(...) +
  ...
  facet_geo(~ ..., data = grd)

hafen avatar Aug 03 '21 02:08 hafen