我正在处理多个国家/地区细分的 shapefile,对于一个国家(冰岛),X 和 Y 坐标似乎在 shapefile 中交换。
数据可以在这里下载:shapefile data; IS_50V:mork_kjordaemi 是相关数据集,在下载下拉菜单中选择“shape-zip”选项。 我一直在 R 中使用“sf”包进行所有 shapefile 工作,并且它与我拥有的所有其他 shapefile 数据完美配合。
library(sf)
ic_2003 <- downloaded_data
st_crs(ic_2003)
给我
Coordinate Reference System:
User input: ISN2016
wkt:
GEOGCRS["ISN2016",
DATUM["Islands Net 2016",
ELLIPSOID["GRS 1980",6378137,298.257222101,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
USAGE[
SCOPE["unknown"],
AREA["Iceland"],
BBOX[59.96,-30.87,69.59,-5.55]],
ID["EPSG",8086]]
head(ic_2003)
给我
Simple feature collection with 6 features and 15 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 63.29577 ymin: -24.53268 xmax: 66.56644 ymax: -13.49462
Geodetic CRS: ISN2016
我试过 ic_2003 <- st_transform(ic_2003, 4326)
但这不能解决问题。
我也试过 ic_2003 <- st_transform(ic_2003, pipeline = "+proj=pipeline +step +proj=axisswap +order=2,1")
,和 here 一样,但这也不能解决问题。
如果我绘制数据
ggplot(ic_2003) +
geom_sf() +
coord_sf()
我得到了正确的形状,但旋转了 90 度并且在世界地图上的错误位置。
您能给我的任何帮助将不胜感激。
答案 0 :(得分:1)
必须有一种 sf
方法可以轻松完成此操作,但您也可以使用 purrr::modify
(其工作方式类似于 map
)来交换所有几何经纬度列(a列表中列表中的列表中的矩阵)而不更改 sf 属性...
library(sf)
library(tidyverse)
ic_2003 <- st_read("mork_kjordaemiPolygon.shp") #from link above
ic_2003 <- ic_2003 %>%
mutate(geometry = modify(geometry, modify, ~list(.[[1]][,c(2,1)])))
ggplot(ic_2003) +
geom_sf() +
coord_sf()