r中的中国省份坐标
Chinese province coordinates in r
有谁知道如何按地区访问中国的坐标。下面的代码显示了我正在寻找中国的相同内容。非常感谢
require(maps)
states_map <- map_data("state")
是您要找的吗?
map_data("world",region="China")
long lat group order region subregion
1 110.8888 19.99194 1 1 China 1
2 110.9383 19.94756 1 2 China 1
3 110.9707 19.88330 1 3 China 1
4 110.9977 19.76470 1 4 China 1
5 111.0137 19.65547 1 5 China 1
6 110.9127 19.58608 1 6 China 1
您可能需要检查以下方法:
# load packages
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(osmextract)
# get polygons in china
poly_china <- openstreetmap_fr_zones[which(openstreetmap_fr_zones$parent == "china"), ]
# extract the coords and save the coords in a data.frame
# you may want to keep the data in matrix format for better performances
poly_china_coords <- as.data.frame(st_coordinates(poly_china))
# extract the region name
my_times <- vapply(st_geometry(poly_china), function(x) nrow(st_coordinates(x)), numeric(1))
poly_china_coords$region_name <- rep(poly_china$name, times = my_times)
# result
head(poly_china_coords)
#> X Y L1 L2 L3 region_name
#> 1 114.875 32.960 1 1 1 Anhui
#> 2 114.860 32.970 1 1 1 Anhui
#> 3 114.870 33.025 1 1 1 Anhui
#> 4 114.880 33.035 1 1 1 Anhui
#> 5 114.895 33.035 1 1 1 Anhui
#> 6 114.890 33.060 1 1 1 Anhui
由 reprex package (v0.3.0)
于 2020-11-06 创建
您可以从 CRAN 安装 sf
,也可以按如下方式安装 osmextract
:
install.packages("remotes")
remotes::install_github("ITSLeeds/osmextract")
数据使用 EPSG:4326 存储,因此 X = 经度和 Y = 纬度。
有谁知道如何按地区访问中国的坐标。下面的代码显示了我正在寻找中国的相同内容。非常感谢
require(maps)
states_map <- map_data("state")
是您要找的吗?
map_data("world",region="China")
long lat group order region subregion
1 110.8888 19.99194 1 1 China 1
2 110.9383 19.94756 1 2 China 1
3 110.9707 19.88330 1 3 China 1
4 110.9977 19.76470 1 4 China 1
5 111.0137 19.65547 1 5 China 1
6 110.9127 19.58608 1 6 China 1
您可能需要检查以下方法:
# load packages
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(osmextract)
# get polygons in china
poly_china <- openstreetmap_fr_zones[which(openstreetmap_fr_zones$parent == "china"), ]
# extract the coords and save the coords in a data.frame
# you may want to keep the data in matrix format for better performances
poly_china_coords <- as.data.frame(st_coordinates(poly_china))
# extract the region name
my_times <- vapply(st_geometry(poly_china), function(x) nrow(st_coordinates(x)), numeric(1))
poly_china_coords$region_name <- rep(poly_china$name, times = my_times)
# result
head(poly_china_coords)
#> X Y L1 L2 L3 region_name
#> 1 114.875 32.960 1 1 1 Anhui
#> 2 114.860 32.970 1 1 1 Anhui
#> 3 114.870 33.025 1 1 1 Anhui
#> 4 114.880 33.035 1 1 1 Anhui
#> 5 114.895 33.035 1 1 1 Anhui
#> 6 114.890 33.060 1 1 1 Anhui
由 reprex package (v0.3.0)
于 2020-11-06 创建您可以从 CRAN 安装 sf
,也可以按如下方式安装 osmextract
:
install.packages("remotes")
remotes::install_github("ITSLeeds/osmextract")
数据使用 EPSG:4326 存储,因此 X = 经度和 Y = 纬度。