我正在尝试使用包ggplot2中的fortify函数将空间对象转换为data.frame.但是我收到了一个错误.例如,遵循Hadley Wickhan的绘制多边形shapefile示例中使用的完全相同的代码,我键入以下命令行:
require("rgdal")
require("maptools")
require("ggplot2")
require("plyr")
utah = readOGR(dsn="/path/to/shapefile", layer="eco_l3_ut")
OGR data source with driver: ESRI Shapefile
Source: ".", layer: "eco_l3_ut"
with 10 features and 7 fields
Feature type: wkbPolygon with 2 dimensions
utah@data$id = rownames(utah@data)
Run Code Online (Sandbox Code Playgroud)
一切似乎都运作正常:
> str(utah)
..@ data :'data.frame': 10 obs. of 8 variables:
.. ..$ AREA : num [1:10] 1.42e+11 1.33e+11 3.10e+11 4.47e+10 1.26e+11 ...
.. ..$ PERIMETER : num [1:10] 4211300 3689180 4412500 2722190 3388270 ...
.. ..$ USECO_ : int [1:10] 164 …Run Code Online (Sandbox Code Playgroud) sudo pip3.4 install gdal从终端(Mac OS X Mavericks)运行后,我收到一条错误消息,指出'col_port.h'未找到该文件并显示以下错误:(command '/user/bin/clang/ failed with exit status 1完整消息如下)。
我有 gdal 1.11(从 kingchaos.com 下载的完整框架版本)和最新版本的 Xcode 命令行工具 -Apple LLVM version 5.1 (clang-503.0.40)(基于 LLVM 3.4svn)
这是我运行sudo pip3.4 install gdal命令后得到的错误:
/usr/bin/clang -fno-strict-aliasing -Werror=declaration-after-statement -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -I/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.11/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.6-intel-3.4/extensions/gdal_wrap.o
extensions/gdal_wrap.cpp:2230:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
res = SWIG_AddCast(res); …Run Code Online (Sandbox Code Playgroud)