Convert and export meshcode area to sf.

meshcode_sf(data, mesh_var, .type, .keep_class = FALSE)

Arguments

data

data.frame

mesh_var

unquoted expressions for meshcode variable.

.type

Specify the subdivision if you want to get a 100m mesh.

.keep_class

Do you want to assign a class to the meshcode column in data.frame? If FALSE, it will be treated as a character type.

Value

sf object

Examples

d <- data.frame(id = seq.int(4),
            meshcode = rmesh(4),
            stringsAsFactors = FALSE)
meshcode_sf(d, meshcode)
#> Simple feature collection with 4 features and 2 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 129.425 ymin: 30.14167 xmax: 141.6375 ymax: 41.64167
#> Geodetic CRS:  WGS 84
#> # A tibble: 4 × 3
#>      id meshcode                                                        geometry
#>   <int> <chr>                                                      <POLYGON [°]>
#> 1     1 60415540 ((141.625 40.45, 141.6375 40.45, 141.6375 40.45833, 141.625 40…
#> 2     2 54396366 ((139.45 36.55, 139.4625 36.55, 139.4625 36.55833, 139.45 36.5…
#> 3     3 62413161 ((141.1375 41.63333, 141.15 41.63333, 141.15 41.64167, 141.137…
#> 4     4 45291374 ((129.425 30.14167, 129.4375 30.14167, 129.4375 30.15, 129.425…