Title: | Utilities for Japanese Mesh Code |
---|---|
Description: | Helpful functions for using mesh code (80km to 100m) data in Japan. Visualize mesh code using 'ggplot2' and 'leaflet', etc. |
Authors: | Shinya Uryu [aut, cre] |
Maintainer: | Shinya Uryu <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.1.0.9000 |
Built: | 2024-12-06 03:25:36 UTC |
Source: | https://github.com/uribo/jpmesh |
Extract administration mesh code
administration_mesh(code, to_mesh_size)
administration_mesh(code, to_mesh_size)
code |
administration code |
to_mesh_size |
target mesh size. That is, 1 for 1km, and 0.5 for 500m. From 80km to 0.100km. |
## Not run: administration_mesh(code = "35201", to_mesh_size = 1) administration_mesh(code = "08220", to_mesh_size = 80) administration_mesh(code = c("08220", "08221"), to_mesh_size = 10) administration_mesh(code = "35", to_mesh_size = 80) administration_mesh(code = c("33", "34"), to_mesh_size = 80) ## End(Not run)
## Not run: administration_mesh(code = "35201", to_mesh_size = 1) administration_mesh(code = "08220", to_mesh_size = 80) administration_mesh(code = c("08220", "08221"), to_mesh_size = 10) administration_mesh(code = "35", to_mesh_size = 80) administration_mesh(code = c("33", "34"), to_mesh_size = 80) ## End(Not run)
Return coarse gather mesh codes
coarse_gather(meshcode, distinct = FALSE)
coarse_gather(meshcode, distinct = FALSE)
meshcode |
|
distinct |
return unique meshcodes |
m <- c("493214294", "493214392", "493215203", "493215301") coarse_gather(m) coarse_gather(coarse_gather(m)) coarse_gather(coarse_gather(m), distinct = TRUE)
m <- c("493214294", "493214392", "493215203", "493215301") coarse_gather(m) coarse_gather(coarse_gather(m)) coarse_gather(coarse_gather(m), distinct = TRUE)
From coordinate to mesh codes.
coords_to_mesh(longitude, latitude, to_mesh_size = 1, geometry = NULL, ...)
coords_to_mesh(longitude, latitude, to_mesh_size = 1, geometry = NULL, ...)
longitude |
longitude that approximately to .120.0 to 154.0 ( |
latitude |
latitude that approximately to 20.0 to 46.0 ( |
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 |
mesh code (default 3rd meshcode aka 1km mesh)
Akio Takenaka: http://takenaka-akio.org/etc/j_map/index.html # nolint
mesh_to_coords()
for convert from meshcode to coordinates
coords_to_mesh(141.3468, 43.06462, to_mesh_size = 1) coords_to_mesh(139.6917, 35.68949, to_mesh_size = 0.250) coords_to_mesh(139.71475, 35.70078) coords_to_mesh(139.71475, 35.70078, to_mesh_size = 0.1) coords_to_mesh(c(141.3468, 139.71475), c(43.06462, 35.70078), mesh_size = c(1, 10)) # Using sf (point as sfg object) library(sf) coords_to_mesh(geometry = st_point(c(139.71475, 35.70078))) coords_to_mesh(geometry = st_point(c(130.4412895, 30.2984335)))
coords_to_mesh(141.3468, 43.06462, to_mesh_size = 1) coords_to_mesh(139.6917, 35.68949, to_mesh_size = 0.250) coords_to_mesh(139.71475, 35.70078) coords_to_mesh(139.71475, 35.70078, to_mesh_size = 0.1) coords_to_mesh(c(141.3468, 139.71475), c(43.06462, 35.70078), mesh_size = c(1, 10)) # Using sf (point as sfg object) library(sf) coords_to_mesh(geometry = st_point(c(139.71475, 35.70078))) coords_to_mesh(geometry = st_point(c(130.4412895, 30.2984335)))
It roughly judges whether the given coordinates are within the mesh area.
eval_jp_boundary(longitude = NULL, latitude = NULL, ...)
eval_jp_boundary(longitude = NULL, latitude = NULL, ...)
longitude |
longitude that approximately to .120.0 to 154.0 ( |
latitude |
latitude that approximately to 20.0 to 46.0 ( |
... |
other parameters |
eval_jp_boundary(139.71471056, 35.70128943)
eval_jp_boundary(139.71471056, 35.70128943)
Convert and export meshcode area to sfc_POLYGON
and sf
.
export_mesh(meshcode) export_meshes(meshcode, .keep_class = FALSE)
export_mesh(meshcode) export_meshes(meshcode, .keep_class = FALSE)
meshcode |
|
.keep_class |
Do you want to assign a class to the meshcode column
in data.frame? If |
sfc object
sf object
export_mesh("6441427712") export_meshes("4128") find_neighbor_mesh("37250395") %>% export_meshes()
export_mesh("6441427712") export_meshes("4128") find_neighbor_mesh("37250395") %>% export_meshes()
Return contains fine mesh codes
fine_separate(meshcode = NULL, .type = "standard", ...)
fine_separate(meshcode = NULL, .type = "standard", ...)
meshcode |
|
.type |
Specify the |
... |
other parameters for paste |
fine_separate("5235") fine_separate("523504") fine_separate("52350432") fine_separate("523504321") fine_separate("5235043211") # to 100m mesh code fine_separate("64414315", .type = "subdivision")
fine_separate("5235") fine_separate("523504") fine_separate("52350432") fine_separate("523504321") fine_separate("5235043211") # to 100m mesh code fine_separate("64414315", .type = "subdivision")
Predict meshcode format and positions for utility and certain.
is_meshcode(meshcode) is_corner(meshcode)
is_meshcode(meshcode) is_corner(meshcode)
meshcode |
|
Rectangle Japanese prefectures positions.
jpnrect
jpnrect
A data frame with 235 rows 11 variables:
long
lat
order
hole
piece
id
group
mesh_code
latitude
longitude
abb_name
## Not run: plot(jpnrect["abb_name"]) ## End(Not run)
## Not run: plot(jpnrect["abb_name"]) ## End(Not run)
Return different meshcode values included in the mesh.
mesh_convert(meshcode = NULL, to_mesh_size = NULL)
mesh_convert(meshcode = NULL, to_mesh_size = NULL)
meshcode |
|
to_mesh_size |
target mesh size. That is, 1 for 1km, and 0.5 for 500m. From 80km to 0.100km. |
If NULL
for to_mesh_size, the meshcode of one small
scale will be returned. If it is the same as the original size,
the meshcode of the input will be return.
mesh_convert(meshcode = "52350432", to_mesh_size = 80) mesh_convert("52350432", 10) # Scale down mesh_convert("52350432", 0.500) mesh_convert("52350432", 0.250) mesh_convert(meshcode = "52350432", 0.125) mesh_convert("523504323", 0.250) mesh_convert("5235043213", 0.125) mesh_convert(64414315, 0.1) # Not changes mesh_convert("52350432", 1) mesh_convert("52350432131", 0.125)
mesh_convert(meshcode = "52350432", to_mesh_size = 80) mesh_convert("52350432", 10) # Scale down mesh_convert("52350432", 0.500) mesh_convert("52350432", 0.250) mesh_convert(meshcode = "52350432", 0.125) mesh_convert("523504323", 0.250) mesh_convert("5235043213", 0.125) mesh_convert(64414315, 0.1) # Not changes mesh_convert("52350432", 1) mesh_convert("52350432131", 0.125)
Returns a unit object of mesh size for the given number.
mesh_size(meshcode, .type = "standard")
mesh_size(meshcode, .type = "standard")
meshcode |
|
.type |
Specify the |
mesh_size("6740")
mesh_size("6740")
mesh centroid
mesh_to_coords(meshcode, ...)
mesh_to_coords(meshcode, ...)
meshcode |
|
... |
other parameters |
Akio Takenaka: http://takenaka-akio.org/etc/j_map/index.html # nolint
coords_to_mesh()
for convert from coordinates to meshcode.
mesh_to_coords("64414277") mesh_to_coords(c("64414277", "64414278"))
mesh_to_coords("64414277") mesh_to_coords(c("64414277", "64414278"))
Shiny gadgets for jpmesh.
mesh_viewer(...)
mesh_viewer(...)
... |
other parameters |
## Not run: mesh_viewer() ## End(Not run)
## Not run: mesh_viewer() ## End(Not run)
Unique 176 meshcodes. The output code may contain values not found in the actual mesh code.
meshcode_set(mesh_size = c(80, 10, 1), .raw = TRUE)
meshcode_set(mesh_size = c(80, 10, 1), .raw = TRUE)
mesh_size |
Export mesh size from 80km to 1km. |
.raw |
return as character. |
character or meshcode
meshcode_set(mesh_size = 80) meshcode_set(mesh_size = 80, .raw = FALSE)
meshcode_set(mesh_size = 80) meshcode_set(mesh_size = 80, .raw = FALSE)
Convert and export meshcode area to sf
.
meshcode_sf(data, mesh_var, .type, .keep_class = FALSE)
meshcode_sf(data, mesh_var, .type, .keep_class = FALSE)
data |
data.frame |
mesh_var |
unquoted expressions for meshcode variable. |
.type |
Specify the |
.keep_class |
Do you want to assign a class to the meshcode column
in data.frame? If |
sf object
d <- data.frame(id = seq.int(4), meshcode = rmesh(4), stringsAsFactors = FALSE) meshcode_sf(d, meshcode)
d <- data.frame(id = seq.int(4), meshcode = rmesh(4), stringsAsFactors = FALSE) meshcode_sf(d, meshcode)
Vector of meshcode
meshcode_vector(x = character(), size = double(), .type = "standard") meshcode(x, .type = "standard") as_meshcode(x, ...) ## S3 method for class 'meshcode' format(x, ...) ## S3 method for class 'subdiv_meshcode' format(x, ...)
meshcode_vector(x = character(), size = double(), .type = "standard") meshcode(x, .type = "standard") as_meshcode(x, ...) ## S3 method for class 'meshcode' format(x, ...) ## S3 method for class 'subdiv_meshcode' format(x, ...)
x |
input meshcode value |
size |
input meshcode size. Default set to |
.type |
Specify the |
... |
path to another function |
meshcode("6441") meshcode(c("6441", "6442")) meshcode(c("6441", "644143")) meshcode("6441431552", .type = "subdivision")
meshcode("6441") meshcode(c("6441", "6442")) meshcode(c("6441", "644143")) meshcode("6441431552", .type = "subdivision")
input should use meshcode under the 1km mesh size.
neighbor_mesh(meshcode, contains = TRUE) find_neighbor_mesh(meshcode = NULL, contains = TRUE)
neighbor_mesh(meshcode, contains = TRUE) find_neighbor_mesh(meshcode = NULL, contains = TRUE)
meshcode |
|
contains |
logical. contains input meshcode (default |
neighbor_mesh(53394501) neighbor_mesh(533945011) neighbor_mesh(533945011, contains = FALSE)
neighbor_mesh(53394501) neighbor_mesh(533945011) neighbor_mesh(533945011, contains = FALSE)
Generate random sample meshcode
rmesh(n, mesh_size = 1)
rmesh(n, mesh_size = 1)
n |
Number of samples |
mesh_size |
Export mesh size from 80km to 1km. |
rmesh(3, mesh_size = 1)
rmesh(3, mesh_size = 1)
Information for the 1:200,000 Scale Maps.
sf_jpmesh
sf_jpmesh
A data frame with 175 rows 9 variables:
meshcode: 80km meshcode
name: names for map
name_roman: names for map (roman)
lng_center: centroid coordiates of mesh
lat_center: centroid coordiates of mesh
lng_error: mesh area
lat_error: mesh area
type: evalueate value to mesh
## Not run: plot(sf_jpmesh["name_roman"]) ## End(Not run)
## Not run: plot(sf_jpmesh["name_roman"]) ## End(Not run)