线和多边形可能有属性,例如,图1.3a中的140等高线有"在海平面140米以上"的标志,两个封闭的等高线有160米的属性。但在本研究区域,若干个非封闭的等高线拥有110米高的属性。140米等高线多边形里的区域拥有超过海平面140米的属性。超过160米等高线的区域采用带有孔的多边形表示(图1.3d),其中心是火山口的一部分,其低于160米。广州网站建设
![]() |
| 图1.3 Maunga Whau(伊甸山)是Auckland火山带近50座火山之一 |
- > library(sp)
- > data(volcano)
- > grey_gamma <- 2.2
- > grys <- grey.colors(8, 0.55, 0.95, grey_gamma)
- > layout(matrix(c(1,2,1,3,1,4),3,2,byrow=TRUE), c(3,1))
- > image(volcano, axes=F, col=grys, asp=1, main="a")
- > contour(volcano, add=T)
- > box()
- > image(volcano, axes=F, col='white', asp=1, main="b")
- > library(maptools)
- > x2 = ContourLines2SLDF(contourLines(volcano))
- > plot(x2, add=T)
- > box()
- > image(volcano, axes=F, col='white', asp=1, main="c")
- > plot(SpatialPolygons(list(Polygons(list(Polygon(coordinates
- + (x2[x2$level == 140,]))), ID="x"))),add = T)
- > box()
- > image(volcano, axes=F, col=grys, asp=1, main="d")
- > x3l1 = coordinates(x2[x2$level == 160,])[[1]][[1]]
- > x3l2 = coordinates(x2[x2$level == 160,])[[1]][[2]]
- > x3 = SpatialPolygons(list(Polygons(list(Polygon(x3l1,hole=F),
- + Polygon(x3l2,hole=T)), ID=c("x"))))
- > SP2TRI = function(x, debug = TRUE){
- + p = x@polygons[[1]] # object of class Polygons
- + pp1 = p@Polygons[[1]] # outer Polygon
- + pp2 = p@Polygons[[2]] # inner Polygon
- + stopifnot(!p1@hole)
- + stopifnot(p2@hole)
- + # find nearest point
- + allcoords = rbind(p1@coords, p2@coords)
- + n1 = nrow(p1@coords)
- + n2 = nrow(p2@coords)
- + dists = as.matrix(dist(allcoords))[((n1+1):(n1+n2)),1:n1]
- + wm = which.min(dists)[1]
- + ind1 = (wm %/% n2) + 1
- + ind2 = wm %% n2
- + if (debug)
- + print(c(ind1,ind2))
- + #plot polygon points:
- + p1p1c = p1@coords
- + p2p2c = p2@coords
- + #plot shortest distance:
- + if (debug)
- + lines(rbind(p1c[ind1,], p2c[ind2,]))
- + if (debug)
- + points(rbind(p1c, p2c))
- + p = rbind(p1c[c(ind1:n1,1:ind1),], p2c[c(ind2:n2,1:ind2),], p1c[ind1,])
- + #polygon(p, col = 'red', border = NULL)
- + polygon(p, angle=45, border = NA, density = 12) }
- > plot(x3, col = 'transparent', add = T)
- > SP2TRI(x3, F)
- > box()
由火山的等高线形成的多边形通常或多或少有圆形的几何特性。在一般情况下,多边形可以有任意形式,某些情况下,甚至可以重叠。一个特殊但常见的情况是,当它们代表某一类别边界,如行政区时,它们不能重叠,并应该划分整个研究区域,研究区中的每个点可以而且必须归属于一个单一的多边形或处于一个或多个多边形的边界上。广州网站建设
网格是一种表示空间数据的特殊形式,在每个网格单元中的值代表网格单元对应实际区域的平均值,或单元中心点的值,或其他传感器观测值。在第一种情况下,我们可以将一个网格单元看成是有序点的特例;在第二种情况下,它们是矩形的集合。在任何情况下,可以从网格的位置计算每个单元的位置、单元的大小和网格单元的组织。网格是铺盖平面的常用方式,它们因为如下原因而显得十分重要:
数码相机和遥感仪器之类的设备基于网格记录数据;
电脑显示屏和投影仪基于网格显示数据;
许多空间或时空模型,如气候模型,使用规则网格来离散空间。




