问题标签 [rgeo-shapefile]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
274 浏览

ruby-on-rails-5 - 如何确定纬度/经度对是否位于 shapefile 多边形内

我在我的 Rails 5 应用程序中使用rgeoand rgeo-shapefilegems。我的目标是加载邻域的 shapefile 并确定纬度/经度点位于哪个邻域内。

在他们的文档中,他们有这个例子。

我不太确定如何从这个例子转向我想做的事情。

0 投票
1 回答
2268 浏览

r - 在 R 中执行 gCentroid 时出错

我无法从 R 中的多边形中获取质心。令人困惑的是,它过去曾经工作过,但突然停止工作了!这是一段代码:

我还可以确认多边形数据的 proj4string 已经存在,如下所示:

我在执行质心代码时收到的错误消息如下:

知道发生了什么吗?如前所述,此代码过去可以正常工作。

谢谢

0 投票
1 回答
185 浏览

r - 使用 rmapshaper::ms_simplify 时出现 ogrInfo 错误

有没有其他人在使用 rmapshaper 包中的 ms_simplify 函数时看到以下错误?

我试图在我的工作区中的 .shp 文件上运行该函数并得到相同的错误。

0 投票
0 回答
55 浏览

r - R 和 GIS:循环保存文件时遇到问题

相关的 NCDF 文件在这里:https ://www.ncdc.noaa.gov/paleo-search/study/19419

我有一个 NCDF 文件,并且正在使用以下循环首先将每个文件保存为 CSV 文件,然后保存为 shapefile:

但是,当我运行上面的代码时,它给了我以下错误:

我做错了什么?我不明白发生了什么,我尝试了各种代码组合和排列。是否应该通过上述代码创建文件“cru_drought_4.csv”?

以下是完整代码,供参考:

0 投票
1 回答
49 浏览

r - R - Best Way to Perform Geospatial Calculations

I am working on a project where I pull crime data from an API, and essentially calculate the density of crime per predefined grid unit. I do this now by putting lat and lon into a data.frame and then calculating the count of points within a radius of a point center. This is computationally expensive as there are thousands of points in the predefined grid and thousands of crime points.

I'm wondering if there is a better way to calculate crime density; I've heard that raster may be valuable?

Some sample data:

Thanks!

0 投票
1 回答
271 浏览

r - 如何联合 2 个相交的多边形接收 2 个单个多边形

如何合并相交的多边形(完美的圆),如下图所示:在此处输入图像描述

到目前为止,我使用了 rgeos 和 sf,但还没有找到一个简单的方法。

@ Ege Rubak 提供了围绕圆的差异创建凸包的提示。使用 rgeos 解决方案看起来像愚蠢的代码。但是,我很难一步获得解决方案。

0 投票
2 回答
1506 浏览

r - Dissolve Overlapping Polygons using difference and union in R

Have the shape file which has multiple polygons with logical division of Zones and Plots. Plots are overlapping over Zones. The task is to dissolve / merge plots with Zones with no overlapping.

enter image description here Here is spplot of the shape file. Here plots are on top of the Field Zones. Also here is the shapefile with overlapped polygons (Zones & Plots): Shapefile

In QGIS, the same was achieved using Extracting the the Zones & Plots, Finding the difference and then dissolving using Union.Now need to program the same in R.

Tried below steps in R but would not able to get the right results , looking for ways how to dissolve this type of overlapping ploygons in R:

0 投票
2 回答
280 浏览

r - 如何使用 raster 包中的函数 crop(x, y, ...) 以便输出是关于 x (shapefile, extent object) 中包含的 y (raster) 的信息

我对 R 有点陌生,尤其是在 R 中使用 GIS,所以我希望我能正确解释这一点。

我想从包 raster 中获取函数 crop (x,y...) 以合并/覆盖(不确定要使用的正确表达式是什么)带有 shapefile 的光栅文件。本质上,shapefile 是瑞典的 5 x 5 公里网格,栅格是瑞典的土地利用栅格。通过使用裁剪函数,我想得到一个结果,对于 shapefile 中的每个 5x5 平方千米,提供从栅格文件中提取的有关每个正方形中土地利用类型的信息。

但是,当我使用crop,然后从我裁剪的“crop(landuse,ekrut)”(见下面的代码)中写入.csv时,我基本上只是将ekrut(shapefile)作为输出csv文件,没有添加列土地利用栅格指示哪个广场具有哪个土地利用类别。

很抱歉,我不能在这里分享实际的 shapefile,如果它会有所作为,可以从这里下载土地利用数据:http: //gpt.vic-metria.nu/data/land/NMD/NMD2018_basskikt_ogeneraliserad_Sverige_v1_0.zip

这是我到目前为止尝试做的事情

这是 GIS 文件的坐标系/投影。每个坐标系都有一个 epsg 代码 ( http://spatialreference.org/ )。

就像我说的那样,当我使用裁剪然后从裁剪的内容中写入.csv 时,我基本上只是将 ekrut(shapefile)作为输出 csv 文件,没有添加土地利用栅格的列,指示哪个广场具有哪个土地利用类别。

我想要一个 .csv,对于每个广场(其中有 19 191 个),它可以为我提供有关该广场存在何种土地利用类型的信息。

如果有更好的方法来解决这个问题,请指出。我希望我的解释很清楚!

谢谢。

0 投票
1 回答
21 浏览

r - 使用命令 over() 时收到错误消息

我有两个形状文件,shp1shp2. 在计算了前者的质心后,我想看看质心在后者的位置。

我的设置是:

执行第二行后,我收到以下错误消息:

知道我应该寻找什么来避免这个错误吗?(注意:grep("NA", row.names(shp1))返回integer(0),也适用于其他形状文件。)

0 投票
0 回答
65 浏览

r - 过滤/子集 SpatialPolygonsDataFrame

我有一个OSpatialPolygonsDataFrame 类型的对象。是吗,有一个变量/列称为Notes. 该列Notes包括字符串文件,其中一些文件中有单词double

我只想过滤double在他们的Notes. 如果它是一个数据表,我们可以做

但这不起作用,以下都不起作用:

任何建议表示赞赏。

PS我熟悉提供可重现示例的想法。但我不知道/想麻烦制作一个。所以,请 ....