[英]Converting spatial polygon to regular data frame without use of gpclib tools
我在R中使用空間數據進行商業應用,並希望使用ggplot2進行數據可視化。 如果您在https://github.com/hadley/ggplot2/wiki/plotting-polygon-shapefiles上運行Hadley的示例,您會發現為了運行fortify
命令,您需要使用gpclibPermit()
啟用gpclib工具。
我正在尋找一種有效的方法(不涉及手動入侵S4對象)來執行fortify
這里的相同操作,即獲取空間多邊形對象並將其轉換為常規數據框,其中行條目包含緯度和縱坐標以及多邊形id。
還有其他人解決了這個嗎?
您還需要安裝rgeos
包。 當maptools
被加載並rgeos
未安裝,示出了以下信息:
> require("maptools")
Loading required package: maptools
Checking rgeos availability: FALSE
Note: when rgeos is not available, polygon geometry
computations in maptools depend on gpclib,
which has a restricted licence. It is disabled by default;
to enable gpclib, type gpclibPermit()
當使用region
參數調用fortify
(就像您鏈接到的示例中那樣),則需要執行一些“多邊形幾何計算”。 如果rgeos
不可用,並且不允許使用gpclib
,則會失敗。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.