[英]Spatstat, Interpolating data points in R
我有降雨的協變量數據。 我也有一個點模式,它表示特定區域內地圖上的住區。 我的問題是我所在地區的部分區域包含海洋,但是海上沒有定居點,但是降雨數據的確包含了該海域。 我希望將降雨值設置為陸地附近點的降雨值。
任何想法如何做到這一點? 也許要找到哪個降雨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
請更清楚地描述您的數據。 您說您有“降雨的協變量數據”:此數據是什么格式? 它是像素圖像(其像素值為雨量),還是雨量計位置和記錄的雨量的數據框? 您有一些位於海上像素的降雨協變量值:您想用這些值做什么? 您有哪些數據可以告訴您哪些位置在海中哪些在陸地上?
如果您有用於定義海岸線的面數據,則可以將其轉換為owin
窗口對象,例如Land
。 然后,如果您的降雨數據是像素圖像Rain
,則可以執行ClipRain <- Rain[Land, drop=FALSE]
來將像素圖像限制在陸地區域(將NA
分配給海上的任何像素)。
如果您在某些位置有降雨數據,請說一個點模式RainRecords
,其中的標記是降雨值,那么Smooth(RainRecords, sigma)
是一個像素圖像,其中包含降雨的內核平滑插值,而nnmark(RainRecords)
是像素圖像其中每個像素值是最近記錄位置的降雨量。 通過剪切或采樣這些圖像,您可能會得到所需的圖像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.