Geotrellis学(踩)习(坑)笔记(一)——核密度分析

本文记录了在Scala环境下使用Geotrellis进行核密度分析的过程,包括生成点数据、应用高斯核函数、理解核密度分析原理以及如何通过TileLayout进行栅格化操作。通过对点数据进行核密度分析,最终生成了表示点分布密度的图像。
摘要由CSDN通过智能技术生成

在geotrellis环境下成功运行了helloworld之后,我第一个尝试的核密度计算~整个过程还是挺艰难的。。。因为对scala非常地不熟,基本属于边写边学的状态T^T

嗯。。首先 核密度分析是什么???

官方文档里对核密度分析有一段这样的介绍:
       Kernel density is one way to convert a set of points (an instance of vector data) into a raster. In this process, at every point in the point set, the contents of what is effectively a small Tile (called a Kernel) containing a predefined pattern are added to the grid cells surrounding the point in question (i.e., the kernel is centered on the tile cell containing the point and then added to the Tile). This is an example of a local map algebra operation. Assuming that the points were sampled according to a probability density function, and if the kernel is derived from a Gaussian function, this can develop a smooth approximation to the density function that the points were sampled from. (Alternatively, each point can be given a weight, and the kernel values can be scaled by that weight before being applied to the tile, which we will do below.)


——首先,核密度分析是一种将点要素的集合(矢量数据)转换为栅格数据的一种手段。在这个例子里,对于每一个点来说,其实是一块小瓦片(被称为核)
核密度的作用是:“ 使用核函数根据点或折线要素计算每单位面积的量值以将各个点或折线拟合为光滑锥状表面。”
嗷懂了~做核密度分析就好比把离散的点想成一个个的山顶,然后我们要利用这些山顶的位置还原出一个地表面(差不多是这样吧。。)

为了进行核密度分析,首先要生成一批点数据:

Scala中的yield的主要作用是记住每次迭代中的有关值,并逐一存入到一个数组中。
scala中的for循环是有返回值的,这里返回的就是 PointFeature[Double]
这样就生成了1000个带有权重的点要素,这里权重的范围为(0,32):
 

 



然后定义一个高斯核函数,并且用高斯核函数生成tile:

 


生成的kde结果如下:
 

 



array里面记录的就是280000个像素的值,这里的tile应该不是瓦片的意思,就是一张大图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值