japanmeshでメッシュポリゴンをsf形式に変換

japanmeshはjpmeshより何かと処理速度が速くて助かる。mesh_codeさえわかれば、それをポリゴンにしてsf形式のtibbleにすることもできる。こんな感じ。

  

japanmeshがなくなってjpgridになったver

(data with meshcode) %>%
  mutate(
    geometry = map(
      .x = mesh_code,
      .f = ~ {
        .x %>% 
          jpgrid::grid_auto() %>% 
          jpgrid::grid_as_sf() 
      }
    )
  ) %>% 
  unnest(geometry) %>% 
  sf::st_as_sf()
  

(data with meshcode) %>%
  mutate(
    geometry = map(
      .x = mesh_code,
      .f = ~ {
        .x %>% 
          japanmesh::mesh_auto() %>% 
          japanmesh::mesh_to_polygon() 
      }
    )
  ) %>% 
  unnest(geometry) %>% 
  sf::st_as_sf()