将 png 地理配准到 R 中的 shapefile
GIS 新手,如果这是基础知识,我深表歉意。我有一张 PNG 无线电信号强度图:
我想提取中国县级平均信号强度数据。
我可以加载中国县的形状文件,并可以创建信号强度的光栅文件,但我不知道如何链接这两个文件,以便获得每个县的信号强度。我必须对数千张 png 执行此操作。谢谢你!
library(raster)
ChinaRD3<-getData('GADM',country="CHN",level=3) #county level
library(rgeos)
ChinaRD3<-gSimplify(ChinaRD3,tol=0.01, topologyPreserve=TRUE)
raster = raster(paste(datadir,"screenshot2.png",sep="")) # the png in my post
v <- extract(raster, ChinaRD3)
# simplify to display mean values
output = unlist(lapply(v, function(x) if (!is.null(x)) mean(x, na.rm=TRUE) else NA ))
New to GIS, apologies if this is basic. I have a png of a radio signal strength map:
I want to extract county-level data on average signal strength in China.
I can load a shapefile of Chinese counties and can create a raster file of signal strength, but I don't know how to link the two so I can get the signal strength in each county. I have to do this to thousands of pngs. Thank you!
library(raster)
ChinaRD3<-getData('GADM',country="CHN",level=3) #county level
library(rgeos)
ChinaRD3<-gSimplify(ChinaRD3,tol=0.01, topologyPreserve=TRUE)
raster = raster(paste(datadir,"screenshot2.png",sep="")) # the png in my post
v <- extract(raster, ChinaRD3)
# simplify to display mean values
output = unlist(lapply(v, function(x) if (!is.null(x)) mean(x, na.rm=TRUE) else NA ))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是对图像进行地理配准的方法
现在是最困难的部分。您需要将颜色转换为值。如果只有带或不带阴影的图例以及国家边界、网格线和海岸线,那就不会那么难了。但如果放大,您可以看到边界是模糊的(也许这些是早期的 jpeg?),产生了很多颜色。使用 terra,您可以将颜色减少到 <= 255,然后也许可以选择主色。但可能有更好的工具(图像魔法?)来首先修复图像,使其仅具有您关心的颜色。
This is how you can georeference the image
Now comes the hard part. You need to translate the colors to values. That would not have been so hard if there was just the legend with or without shading and the country borders, gridlines and coastlines. But if you zoom in you can see that the borders are blurred (perhaps these were jpegs earlier in their life?), creating very many colors. With terra you can reduce the colors to <= 255, and then perhaps select the dominant colors. But there probably are better tools (image magick?) to first fix the image so that it only has the colors you care about.