我正在使用 ggplot2 繪制投影多邊形(sf)物件。當我使用它時,ggplot 將軸繪制為度數(北/南 - 東/西),但是我更喜歡將軸保持為北東(這是正確的)。
這是一個例子:
library(rnaturalearth)
library(ggplot2)
library(sf)
# Get world polygons
world <- ne_countries()
# Reproject to equal area lambers projection
proj <- " proj=laea lat_0=0 lon_0=-70 x_0=0 y_0=0 datum=WGS84 units=km no_defs"
world_proj <- spTransform(world, CRS(proj))
# Convert to sf
world_proj <- st_as_sf(world_proj)
# Plot it --- showing correctly as easting-northing
plot(world_proj, axes = T, max.plot = 1,
xlim = c(-3200, 4500), ylim = c(-4900, 4900))
# Plot with ggplot - converting to degrees north/south - west/east
# I need it in north easting!
ggplot()
geom_sf(data = world_proj)
coord_sf(xlim = c(-3200, 4500), ylim = c(-4900, 4900))
我試圖更改 coord_sf 上的引數,但沒有幫助。我很感激你能給的任何建議!
uj5u.com熱心網友回復:
改變datum論點:
ggplot()
geom_sf(data = world_proj)
coord_sf(xlim = c(-3200, 4500), ylim = c(-4900, 4900),
datum=st_crs(world_proj))

檔案:
datum: CRS that provides datum to use when generating graticules.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/468208.html
上一篇:將R中的兩個密度圖合并為一個圖
下一篇:使用ggplot2創建子圖
