splancs包中的csr函数生成多边形外的点

splancs包中的csr函数生成多边形外的点,r,ggplot2,spatial,R,Ggplot2,Spatial,在使用splancs包中的csr函数为美国大陆生成点模式时,我发现一些点是在密歇根湖和伊利湖的小部分生成的。下面是一个例子 # 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")

在使用
splancs
包中的
csr
函数为美国大陆生成点模式时,我发现一些点是在密歇根湖和伊利湖的小部分生成的。下面是一个例子

# 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
#加载包
图书馆(地图)
图书馆(GG2)
图书馆(苏丹人民解放军)
#获取多边形的坐标

usaSplancs'
csr
函数仅适用于简单的单环多边形。为了准确地看到您正在给它喂食什么,请使用
polymap

polymap(country)

哎呀。你们国家有一些奇怪的地方。得到一个更好的多边形