从spseg()输出中获取唯一值

时间:2015-09-21 00:30:48

标签: r spatial sp

我使用套餐seg获取西雅图西澳大利亚州人口普查区的种族隔离值。函数spseg()计算四种隔离度量,spplot函数将每个域的隔离结果映射到其质心。

如何获得每个点中创建的各个道路值的向量,如spplot输出?

(下载有问题的Seattle shapefile

library(seg)
library(rgdal)

# load data
sea.shp <- readOGR(".","seattle")

# run segregation measure
sea.seg <- spseg(x=sea.shp, data=sea.shp@data[,2:5])
print(sea.seg, digits=3)
as.list(sea.seg)
spplot(sea.seg)

spseg输出为整组视图提供了四种隔离度量。我想得到每个这些片段的值的向量。换句话说,对于spplot中的每个点,这些值中的每一个是什么?

非常感谢你!

2 个答案:

答案 0 :(得分:1)

尝试

spplot(as(sea.seg, "SpatialPointsDataFrame")["his2010"])

你会得到个人价值,例如首先转换为SpatialPointsDataFrame,然后转换为data.frame

x <- as(as(sea.seg, "SpatialPointsDataFrame"), "data.frame")

您可以从data.frame获得

的单个向量
x$his2010

或者,如果您快捷方式,请

as(sea.seg, "SpatialPointsDataFrame")[["his2010"]]

的输出中,sea.seg每个区域都没有其他措施。
`str(sea.seg)`

答案 1 :(得分:0)

令我失望的是,tempDocument.open( "text/html" ); tempDocument.write( pageContent ); tempDocument.close(); 仅绘制spplot的实际数据,这是每个种族群体的比例,而不是sea@data[,2:5]函数计算的隔离度量。

spseg

感谢您的投入!