- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在将一系列集水多边形(来自 shapefile)叠加到 SpatialPixelsDataFrame 对象上时,我遇到了一个奇怪的问题。有 70 个集水区,但我得到了 NA
s 用于 60 个集水区。
数据在 Dropbox 上可用,以下脚本将下载、解压缩文件等,并创建一个可重现的示例。
## load packages required
require(rgdal)
require(sp)
## proj4 string
BNG <- CRS("+init=epsg:27700")
## load in the grid
download.file("https://www.dropbox.com/s/7dvcf6ddo6r3043/depogrid.rds?dl=1",
"./depogrid.rds", method = "wget")
myGrid <- readRDS("depogrid.rds")
## convert to spatial pixels
depo.sp <- SpatialPixelsDataFrame(data.matrix(myGrid[, 1:2]),
data = myGrid[, 3, drop = FALSE],
proj4string = BNG)
## load the shapefile
download.file("https://www.dropbox.com/s/bwzmeumnrja3c0o/dart.zip?dl=1",
"./dart.zip", method = "wget")
unzip("./dart.zip")
shp <- readOGR(".", "DARTall")
## project shp to OSGB36
shp <- spTransform(shp, BNG)
## overlay shapefile on depo grid
depo.dart <- over(shp, depo.sp)
NA
s:
> head(depo.dart)
Deposition
0 NA
1 NA
2 NA
3 NA
4 NA
5 0.2604089
> sum(is.na(depo.dart[,1]))
[1] 60
> nrow(depo.dart)
[1] 70
NA
s 因为网格覆盖了整个英国地区并且集水区很小,所以我可能做错了什么!如果是这样,我做错了什么,我该如何解决?我想得到
Deposition
的平均值(
SpatialPixelsDataFrame
数据)用于
shp
中的 70 个流域中的每个流域.
depo.sp
相同.
> over(shp, depo.sp, returnList = TRUE)
[[1]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[2]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[3]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[4]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[5]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[6]]
Deposition
3143 0.2604089
[[7]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[8]]
Deposition
3289 0.1139663
[[9]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[10]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[11]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[12]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[13]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[14]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[15]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[16]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[17]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[18]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[19]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[20]]
Deposition
3585 0.8610678
[[21]]
Deposition
3288 0.2242067
[[22]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[23]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[24]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[25]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[26]]
Deposition
3141 0.3296081
[[27]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[28]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[29]]
Deposition
3438 0.3609788
[[30]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[31]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[32]]
Deposition
3287 0.4812801
[[33]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[34]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[35]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[36]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[37]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[38]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[39]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[40]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[41]]
Deposition
3436 0.3223757
[[42]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[43]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[44]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[45]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[46]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[47]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[48]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[49]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[50]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[51]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[52]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[53]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[54]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[55]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[56]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[57]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[58]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[59]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[60]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[61]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[62]]
Deposition
2580 0.2820617
[[63]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[64]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[65]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[66]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[67]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[68]]
Deposition
3141 0.3296081
3287 0.4812801
3288 0.2242067
3438 0.3609788
[[69]]
[1] Deposition
<0 rows> (or 0-length row.names)
[[70]]
[1] Deposition
<0 rows> (or 0-length row.names)
> str(over(shp, depo.sp, returnList = TRUE))
List of 70
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 1 obs. of 1 variable:
..$ Deposition: num 0.26
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 1 obs. of 1 variable:
..$ Deposition: num 0.114
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 1 obs. of 1 variable:
..$ Deposition: num 0.861
$ :'data.frame': 1 obs. of 1 variable:
..$ Deposition: num 0.224
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 1 obs. of 1 variable:
..$ Deposition: num 0.33
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 1 obs. of 1 variable:
..$ Deposition: num 0.361
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 1 obs. of 1 variable:
..$ Deposition: num 0.481
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 1 obs. of 1 variable:
..$ Deposition: num 0.322
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 1 obs. of 1 variable:
..$ Deposition: num 0.282
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 4 obs. of 1 variable:
..$ Deposition: num [1:4] 0.33 0.481 0.224 0.361
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
$ :'data.frame': 0 obs. of 1 variable:
..$ Deposition: num(0)
最佳答案
如果您愿意进行实验并愿意使用 raster
包,这是一个可能的解决方案。让我们知道。
诀窍是,在栅格上覆盖多边形时,指定 small = TRUE
,因为多边形的中心并不总是包括单元中心(见 ?extract
)。
If y represents polygons, a value is also returned for relatively small polygons (e.g. those smaller than a single cell of the Raster* object), or polygons with an odd shape, for which otherwise no values are returned because they do not cover any raster cell centers.
library(raster)
shp.raster <- raster(shp)
depo.sp.raster <- raster(depo.sp)
plot(depo.sp.raster)
plot(shp, add = TRUE)
zoom(depo.sp.raster) # click in the corners around the area to zoom in
plot(shp, add = TRUE)
res.out <- extract(depo.sp.raster, shp, layer = 1, small = TRUE)
table(unlist(lapply(res.out, is.null)))
> head(res.out)
[[1]]
0.0334963
[[2]]
0.2604089
[[3]]
[1] 0.5466648 0.7929624 0.4214012
[[4]]
[1] 0.2604089 0.3149418 0.5343358 0.0334963
[[5]]
0.5561869
[[6]]
0.2604089
关于r - 在 SpatialPixelsDataFrame 上叠加 shapefile 时产生的 NA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13565179/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!