2013-06-27 57 views
1

我的工作R 3.0.1和我做了模擬的集羣泊松過程,R通常有一個默認的區域基本上是一個盒子,在接下來的圖片可以看到我的模擬:如何在R的任意區域模擬空間泊松過程?

enter image description here

到目前爲止一切正常,麻煩的是,我想要做的是模擬相同的distribution但使用地理區域,但我不知道如何更改參數以便使用地理座標獲得不同的區域。例如:

enter image description here

綜上所述,基本上是我想要做的是找出如何改變這種面積較大的一個,以使相同的模擬但隨着新區域。這裏是我試過的代碼:

library(spatstat) 

sim1 = rpoispp(100) 
plot(sim1) 
+0

你的意思,你要模擬的過程中採取的是地圖中的地方嗎?即,不只是一個簡單的矩形區域? –

+0

好吧,它可能是一個包含地圖的矩形區域。 – Castiblanco

+0

讀取'?rpoispp'的表格我學到了一個參數'win',它接受類「owin」的對象,並且是「模擬模式的窗口」。 – Roland

回答

4

你可以試試這個:

require(spatstat) 
require(maps) 

lambda = 0.1 # intensity of the process 
lon = c(-100,-70) # domain's longitude 
lat = c(-40,10) # domain's latitude 

sim = rpoispp(lambda, win=c(lon,lat)) 

# do the plot 
par(mar=c(1,1,1,1)) 
map("world", xlim=lon, ylim=lat, fill=TRUE) 
map.axes() # add axes 
plot(sim, chars=19, cols="red",cex=0.5, add=TRUE) 

# add other process 

lon1 = c(-95,-85) # other area 
lat1 = c(-5,5) 
sim1 = rpoispp(5*lambda, win=c(lon1,lat1)) 
plot(sim1, chars=19, cols="blue",cex=0.5, add=TRUE) 

Final map

+0

這工作真好......現在我有一個小問題,我可以將軸座標設置爲形狀文件嗎? – Castiblanco

+0

什麼是形狀文件? –

+0

這是Shapefile http://en.wikipedia.org/wiki/Shapefile – Castiblanco