Spatstat,在R中内插数据点

时间:2018-07-17 11:03:09

标签: r interpolation spatstat

我有降雨的协变量数据。我也有一个点模式,它表示特定区域内地图上的住区。我的问题是我所在地区的部分区域包含海洋,但是海上没有定居点,但是降雨数据的确包含了该海域。我希望将降雨值设置为陆地附近点的降雨值。

任何想法该怎么做? 也许要找到哪个降雨x和y坐标代表海洋,我想创建一个包含所有平方千米中心点的数据框,然后为匹配的位置导入降雨值,并查看哪些位置没有值。但我卡住了。这是我的代码:

> window<- data.frame(Lon=c(-1.560367, -1.078330 ), Lat=c( 50.576342, 51.243823))
> coordinates(window) <- ~Lon + Lat
> 
> 
> proj4string(window) = CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
> 
> proj4string(winch2) <- latlong
> 
> window <- spTransform(window, bng)
> 
> (floor (coordinates (window) / 1000) + 0.5) * 1000
> 
> W2<- owin(c(431500,464500), c( 75500, 149500))
> 
> Region<-Settlements[W2]     ###Settlements is my data
> 
> rain_im[W2]    ###rain is my covariate as a pixel image
> 
> as.data.frame(rain_im[W2])  ###Converted this into a pixel image
> 
> `summary(Region)`



Marked planar point pattern:  308 points
Average intensity 1.261261e-07 points per square unit

Coordinates are given to 2 decimal places
i.e. rounded to the nearest multiple of 0.01 units

marks are numeric, of type ‘double’
Summary:
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
   2.375   19.000   47.500  103.029   88.364 5500.000 

Window: rectangle = [431500, 464500] x [75500, 149500] units
Window area = 2.442e+09 square units

1 个答案:

答案 0 :(得分:0)

请更清楚地描述您的数据。您说您有“降雨的协变量数据”:此数据是什么格式?它是像素图像(其像素值为雨量),还是雨量计位置和记录的雨量的数据框?您有一些位于海上像素的降雨协变量值:您想用这些值做什么?您有什么数据可以告诉您哪些位置在海中哪些在陆地上?

如果具有定义海岸线的面数据,则可以将其转换为owin窗口对象,例如Land。然后,如果您的降雨量数据是像素图像Rain,则只需执行ClipRain <- Rain[Land, drop=FALSE]即可将像素图像限制在陆地区域(将NA分配给海上的任何像素)。

如果您在某些位置有降雨数据,请说出点模式RainRecords,其中的标记是降雨值,那么Smooth(RainRecords, sigma)是一个像素图像,其中包含降雨的内核平滑插值,而{{ 1}}是一个像素图像,其中每个像素值是最近记录位置的降雨。通过剪切或采样这些图像,您可能会得到所需的内容。