1

我正在尝试学习如何使用 ggplot2 绘制 shapefile,我在以下位置找到了一个 wiki:

https://github.com/hadley/ggplot2/wiki/plotting-polygon-shapefiles

我下载并解压了提供的 zip 文件到我桌面上的新目录 ( http://www.epa.gov/nheerl/arm/documents/design_doc/ecoregion_design.zip )。

我开始逐行阅读这篇文章,但我遇到了fortify.

require("rgdal")
require("maptools")
require("ggplot2")
require("plyr")

> my_dsn <- "directory here"
> 
>   utah = readOGR(dsn=my_dsn, layer="eco_l3_ut")
OGR data source with driver: ESRI Shapefile 
Source: "directory here", layer: "eco_l3_ut"
with 10 features and 7 fields
Feature type: wkbPolygon with 2 dimensions
>   utah@data$id = rownames(utah@data)
>   utah.points = fortify(utah, region="id")
Error: isTRUE(gpclibPermitStatus()) is not TRUE

我查看了?fortify帮助页面并了解了如何使用它。我认为它被正确使用。我还在 SO 上发现了另一个具有相同错误的问题,

在 R (ggplot) 中使用 fortify 函数时出错

但我不知道如何应用我的解决方案所说的内容。如果我现在可以访问保管箱,我可能会有所帮助,但我没有。

4

1 回答 1

2

简短的回答是安装 rgeos 包并将其包含在顶部。

可以在这里(和其他地方)找到更长的答案:https ://stat.ethz.ch/pipermail/r-sig-geo/2012-July/015685.html

于 2014-02-13T18:25:59.837 回答