문제

I'm trying to learn how to plot shapefiles with ggplot2 and I found a wiki at:

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

I downloaded and extracted the zip file provided into new directory on my desktop ( http://www.epa.gov/nheerl/arm/documents/design_doc/ecoregion_design.zip ).

I started reading through the article, going line by line but I'm running into a problem with 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

I looked at the ?fortify help page and get the jist of how it should be used. I think its being used correctly. I also found another question with the same error on SO,

Getting error while using fortify function in R (ggplot)

but I can't figure out how to apply what is being said for my solution. I might help if I had access to dropbox right now but I don't.

도움이 되었습니까?

해결책

The short answer is to install the rgeos package and include it at the top.

A longer answer can be found here (and elsewhere): https://stat.ethz.ch/pipermail/r-sig-geo/2012-July/015685.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top