我已经在GIS堆栈交换中发布了这个问题,但它没有看到太多的流量.
我是一名GIS用户,几年来一直使用R进行统计,我很高兴看到很多新的GIS功能被发布(光栅,shapefile,rgdal等).
我在R中做了很多数据库和表操作,因此能够从shapefile中添加和删除属性是一个强大的潜力.
我希望我只是错过了那里的东西,但我似乎无法找到一个很好的方法来添加或删除shapefile属性表中的属性.
Overflow中的任何人都可以回复我的GIS帖子吗?或者我可以被告知如何将我的列表属性表放入数据帧并返回以替换当前属性表?
自我原帖后的一些进展:
这是在弄清楚如何采取我的属性表appart(.dbf),添加东西,现在我试图把它重新组合起来替换原来的dbf.
>libary(raster); library(rgdal); library(shapefiles)
>shp<-shapefile(Shape) # D.C. area airport polygons
>summary(shp) #Shapefile properties
Object of class SpatialPointsDataFrame
Coordinates:
min max
coords.x1 281314.2 337904.7
coords.x2 4288867.0 4313507.0
Is projected: TRUE
proj4string :
[+proj=utm +zone=18 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0]
Number of points: 4
Data attributes:
ObjectID LOCID NAME FIELD STATE STATE_FIPS ACAIS TOT_ENP TYPE
Min. :134.0 Length:4 Length:4 Length:4 Length:4 Length:4 Length:4 Min. : 271 Length:4
1st Qu.:242.8 Class :character …Run Code Online (Sandbox Code Playgroud) 我想writeRaster编写我在R中构建的RAT(栅格属性表).
我正在运行R 3.0.1,光栅2.1-49和rgdal 0.8-10.
我的输入栅格看起来像这样:
r <-raster("F:/test.img")
class : RasterLayer
dimensions : 3, 3, 9 (nrow, ncol, ncell)
resolution : 30, 30 (x, y)
extent : 347325, 347415, 4301655, 4301745 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=18 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : F:\test.img
names : test
values : 1, 19 (min, max)
Run Code Online (Sandbox Code Playgroud)
然后我构建我的属性表:
r <- ratify(r)
rat <- levels(r)[[1]]
rat$Pixel_Values <- c(1, 7, 8, 9, 19)
rat$Class_Names <- c("A", "B", "C", "D", "E") …Run Code Online (Sandbox Code Playgroud)