我有下面的代码,用于在 ggplot 中生成基于象限的值的简单极坐标图(来自纬度和经度中心点的风半径),如下所示:
我想将这些极坐标图提取到 SpatialPolygons 对象,这样我就可以将它们绘制为地图上的多边形,与此类似:
有没有什么方法可以将像这样的 ggplot 对象提取到 SpatialPolygons、shapefile 或某种数据框,以便使用 ggplot/ggmap 在地图上绘制?即使是进一步探索的建议也会很有用。提前致谢。
我的数据框:
winds <- data.frame(WindField = c(34, 50, 64, 34, 50, 64, 34, 50, 64, 34, 50, 64),
Quadrant = c("NE", "NE", "NE", "SE", "SE", "SE",
"SW", "SW", "SW", "NW", "NW", "NW"),
Radius = c(222, 93, 37, 139, 46, 37, 74, 19, 9, 222, 93, 37))
quads <- c("NE", "SE", "SW", "NW")
Run Code Online (Sandbox Code Playgroud)
我的 ggplot 代码:
ggplot() +
geom_col(data = winds,
aes(x = factor(Quadrant, levels = quads),
y = …Run Code Online (Sandbox Code Playgroud)