0

csrパッケージの関数を使用して米国本土のポイント パターンをsplancs生成すると、ミシガン湖とエリー湖の小さなセクションでいくつかのポイントが生成されることがわかりました。以下に例を示します。

# Load packages
library(maps)
library(ggplot2)
library(splancs)

# Obtain coordinates of US polygon
usa <- map_data("usa")
country <- usa[c(1,2)]
colnames(country) <- c("x", "y")
country <- as.points(country)

# Generate points under complete spatial randomness
random <- csr(country, 30000)
random <- data.frame(random)

# Obtain coordinates of state outlines
state <- map_data("state")

# Plot the points on a map of the US
p <- ggplot(state, aes(x = long, y = lat)) +
geom_path(color = "black", aes(group = group)) +
geom_point(data = random, size = 0.7, aes(x = xc, y = yc), color = "gray") +
theme_bw()
p

上記のコードは、ミシガン湖とエリー湖のいくつかのポイントを明確に示すマップを生成します。これを防ぐ方法はありますか?

4

1 に答える 1

0

Splancs のcsr機能は、単純な単一リング ポリゴンに対してのみ適切に機能します。何を食べているかを正確に確認するには、次を使用しますpolymap

polymap(country)

ここに画像の説明を入力

おっとっと。あなたの国の多角形にはいくつかの奇妙な点があります。より良いポリゴンを取得します。

于 2013-08-30T16:58:57.997 に答える