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