Spatstat中的Quadrats [英] Quadrats in Spatstat

查看:81
本文介绍了Spatstat中的Quadrats的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在做探索性分析,目的是绘制一个四边形图,确定是否存在完全的空间随机性(在视觉上和使用卡方检验),等等.但是,我在绘制四边形图时遇到了麻烦.我以前曾问过这个问题,导致我重新规划了数据.

I am now doing exploratory analysis and the objective is to plot a quadrat map, determine if there exists complete spatial randomness (visually and using chi-square test), etc. However, I am having trouble plotting a quadrat map. I previously asked this question that led me to reproject my data.

这是我的代码:

library(rgdal) #Brings Spatial Data in R
library(spatstat) # Spatial Statistics
library(maptools)
library(raster)

# Load nyc zip code boundary polygon shapefile 
s <- readOGR("/Users/my_name/Documents/fproject/zip","zip")
nyc <- as(s,"owin")

### OGR data source with driver: ESRI Shapefile 
#Source: "/Users/my_name/Documents/project/zip", layer: "zip"
#with 263 features

# Load nyc arrests point feature shapefile
s <- readOGR("/Users/my_name/Documents/project/nycarrests/","geo1")

### OGR data source with driver: ESRI Shapefile 
#Source: "/Users/my_name/Documents/project/nycarrests", layer: "geo1"
#with 103376 features
#It has 19 fields

#Converting the dataset into a point pattern
utm <- "+proj=utm +zone=32 +datum=WGS84"
x <- spTransform(s,utm)
arrests <- as(x,"ppp")

marks(arrests) <- NULL
Window(arrests) <- nyc 
plot(arrests, main="2020", cols="dark green",pch=20)

### Quadrat density 2020 
Q <- quadratcount(arrests, nx= 3, ny=3)
plot(arrests, pch=20, cols="grey70", main="2020")  # Plot points
plot(Q, main="2020", add=TRUE)  # Add quadrat grid

在这里,我的数据点受到NYC邮政编码边界的约束,但它们没有显示在我的地图上.我该怎么做才能解决此问题?

Here, my data points are constrained by NYC zip code boundaries, but they do not show up on my map. What can I do to fix this?

推荐答案

您没有提供太多信息.例如,您可以(每次)显示(打印) s ,或 crs(s)(均已加载光栅包)

You are not providing much information. For example you could show (print) s (each time), or crs(s) (both with the raster package loaded)

无论哪种方式,几乎可以肯定是因为您使用的坐标参考系不同.您将一个更改为"UTM区域21",但未更改其他.他们可能是不同的.另外,第21区不适用于纽约.

Either way, it is almost certainly because the coordinate reference systems you are using are not the same. You change one to "UTM zone 21", but you do not change the others. They are probably different. Also, zone 21 is not appropriate for New York.

这篇关于Spatstat中的Quadrats的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆