使用R中的SF对象将比例更改为LAT/LONG
恐怕我只是无法弄清楚。我正在尝试使用县的集合来绘制各州/美国地区的地区; 这是一个示例文件(ak_test.csv)。
数据取自urbn_map
数据集territories_counties
。我的理解是,此数据使用“简单功能”(sf
)几何形状,因此所有多边形数据都存储在每个县级对象的几何
列中。
这是我要绘制的代码:
g <- ggplot(ak_test)
g <- g + geom_sf(aes(geometry = geometry, fill = Region),
color = "black", show.legend = FALSE)
g <- g + geom_sf_label_repel(aes(geometry = geometry, label = County))
g <- g + coord_sf()
g
我不了解轴上的单元,但我希望它们在lat/long中 - 我认为这是目的coord_sf()
函数的功能。我尝试添加X和Y限制(使用状态的大致边界),但是当我这样做时,图像从页面上掉落。
在其他情况下,输出似乎旋转/倾斜(请参阅俄勒冈州/爱达荷州/蒙大拿州的图像) - 我希望转换为lat/long。 net/5dq97.png“ rel =“ nofollow noreferrer”>
I'm afraid I just cannot figure this out. I am trying to plot regions in states/US territories using collections of counties; here is an example file (AK_Test.csv).
The data is taken from the urbn_map
data set territories_counties
. It's my understanding that this data uses the "simple features" (sf
) geometry, so all of the polygon data is stored in the geometry
column for each county-level object.
Here is the code I am using to plot:
g <- ggplot(ak_test)
g <- g + geom_sf(aes(geometry = geometry, fill = Region),
color = "black", show.legend = FALSE)
g <- g + geom_sf_label_repel(aes(geometry = geometry, label = County))
g <- g + coord_sf()
g
I do not understand the units on the axes, but I would like them to be in lat/long -- I thought that was the purpose of the coord_sf()
function. I've tried adding x and y limits (using the approximate boundaries of the state), but when I do that, the image falls off the page.
In other cases, the output appears rotated/tilted (see image with Oregon/Idaho/Montana) - I'm hoping that the conversion to lat/long addresses this as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些数字是< / em>纬度 /经度,但它们与所需的坐标系统不同。您需要使用适当的CRS重新投影数据:
注意,我不知道
geom_sf_label_repel
来自哪里附带问题。These numbers are latitude / longitude, but they are in a different co-ordinate system from the one you want. You need to re-project the data using an appropriate crs:
Note, I have no idea where
geom_sf_label_repel
comes from, so I have used non-repeling labels since they are incidental to the question.