From coordinate to mesh codes.

coords_to_mesh(longitude, latitude, to_mesh_size = 1, geometry = NULL, ...)

Arguments

longitude

longitude that approximately to .120.0 to 154.0 (double)

latitude

latitude that approximately to 20.0 to 46.0 (double)

to_mesh_size

target mesh size. That is, 1 for 1km, and 0.5 for 500m. From 80km to 0.100km.

geometry

XY sfg object

...

other parameters

Value

mesh code (default 3rd meshcode aka 1km mesh)

References

Akio Takenaka: http://takenaka-akio.org/etc/j_map/index.html # nolint

See also

mesh_to_coords() for convert from meshcode to coordinates

Examples

coords_to_mesh(141.3468, 43.06462, to_mesh_size = 1)
#> <meshcode[1]>
#> [1] 64414277
coords_to_mesh(139.6917, 35.68949, to_mesh_size = 0.250)
#> <meshcode[1]>
#> [1] 5339452532
coords_to_mesh(139.71475, 35.70078)
#> <meshcode[1]>
#> [1] 53394547
coords_to_mesh(139.71475, 35.70078, to_mesh_size = 0.1)
#> <subdiv_meshcode[1]>
#> [1] 5339454701
coords_to_mesh(c(141.3468, 139.71475), 
               c(43.06462, 35.70078), 
               mesh_size = c(1, 10))
#> <meshcode[2]>
#> [1] 64414277 53394547
# Using sf (point as sfg object)
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
coords_to_mesh(geometry = st_point(c(139.71475, 35.70078)))
#> <meshcode[1]>
#> [1] 53394547
coords_to_mesh(geometry = st_point(c(130.4412895, 30.2984335)))
#> <meshcode[1]>
#> [1] 45303355