栅格数据的缓冲区分析主要可以分成两种,一种是先将矢量数据做缓冲区之后进行栅格化,另一种是直接将栅格数据进行缓冲区分析。下面是这两种方式的代码:
将矢量数据先进行buffer再栅格化:
def bufferPoints(): Unit ={
val extent:Extent = Extent(0, 0, 80, 80)
val re =RasterExtent(extent, 100, 100)
val points = Seq(
Point(30,30).buffer(3),
Point(20,20).buffer(3),
Point(24,25).buffer(3),
Point(15,20).buffer(3))
val rpts:Tile = Rasterizer.rasterizeWithValue(points,re, 0x55)
rpts.renderPng(colorMap1).write("D:\\IdeaProjects\\ScalaDemo\\data\\buffer\\buffer_point.tif")
}
先栅格化之后再对栅格数据进行buffer:
def bufferTiles(): Unit ={
val featureRDD :RDD[Geometry]= sc.parallelize(points)
val extent:Extent = Extent(0, 0, 80, 80)
val tl = TileLayout(10,10,10,10)
val layout = LayoutDefinition(extent, tl)
val celltype:CellType=IntCellType
val tilesRDD : RDD[(SpatialKey, Tile)] with Metadata[LayoutDefinition] = featureRDD.rasterize(35, celltype, layout)
val neighborhood = Square(3)
tilesRDD.bufferTiles(neighborhood.extent)
val tileResult = tilesRDD.collect()
for(tile <- tileResult){
}
val stitched = TileLayoutStitcher.stitch(tileResult)._1
stitched.renderPng(colorMap1).write("D:\\IdeaProjects\\ScalaDemo\\data\\buffer\\buffer_tile.tif")
}
|
|