简体   繁体   English

如何为栅格设置正确的投影?

[英]How to set proper projection for raster?

I'm trying to plot rainfall data from weather radar. 我正试图绘制天气雷达的降雨数据。 Data file is 900x900 points matrix (900x900km). 数据文件是900x900点矩阵(900x900km)。 Projection informations from original cappi file: 来自原始cappi文件的投影信息:

<projection lat_lr="48.133400" lat_ul="56.186500" type="aeqd" lon_lr="25.157600" size_x="900" size_y="900" lon_ul="11.812900">
    <lon_0>19.092600</lon_0>
    <lat_0>52.346800</lat_0>
    <ellps>+ellps=sphere</ellps>
</projection>

I'm reading data file (example: https://meteomodel.pl/examples/out.txt ) to matrix, and convert to raster: 我正在读取数据文件(例如: https//meteomodel.pl/examples/out.txt )到矩阵,并转换为栅格:

a1 = as.matrix(read.table("/home/user/out.txt", header=F, as.is=TRUE))
a1[a1==0] <- NA
maxDBz <- 95.5
minDBz <- -31.5
step <- (maxDBz - minDBz) / 254
a1 <-  minDBz + (a1 * step)
r <- raster(a1)

Then I'm trying to set extent and CRS: 然后我试图设置范围和CRS:

e <- extent(11.812900, 25.157600, 48.133400, 56.186500)
r <- setExtent(r, e)
crs(r) <- "+proj=aeqd +lat_0=52.346800 +lon_0=19.092600 +x_0=900 +y_0=900 +ellps=sphere +datum=WGS84 +units=km +no_defs"

Data are plotted, however projection is incorrect: 绘制数据,但投影不正确:

https://meteomodel.pl/examples/Rplot01.png https://meteomodel.pl/examples/Rplot01.png

Correct image from Polish Institute of Meteorology and Water Management: 来自波兰气象和水管理研究所的正确图像:

https://meteomodel.pl/examples/cappi.png https://meteomodel.pl/examples/cappi.png

What am I doing wrong? 我究竟做错了什么?

What you are doing wrong is setting the extent using lon/lat crs, whereas the data have "+proj=aeqd . These need to match. I do not know what the correct extent is, but you can approximate it like this: 你做错了是使用lon / lat crs设置范围,而数据有"+proj=aeqd 。这些需要匹配。我不知道正确的范围是什么,但你可以像这样近似:

p <- "+proj=aeqd +lat_0=52.346800 +lon_0=19.092600 +x_0=900 +y_0=900 +ellps=sphere +datum=WGS84 +units=km +no_defs"

e <- extent(11.812900, 25.157600, 48.133400, 56.186500)
r <- raster()
extent(r) <- e
rr <- projectExtent(r, p)
extent(rr)
#class      : Extent 
#xmin       : -541.0182 
#xmax       : 452.2122 
#ymin       : -488.8849 
#ymax       : 431.1854 

The txt file provided sugests that the extent you want is 提供的txt文件表示您想要的范围

e <- extent(-449997.470, 451000.522, -451003.637, 449998.274) 

And that suggests that the units in your crs should be m , not km 这表明你的单位中的单位应该是m而不是km

p <- "+proj=aeqd +lat_0=52.346800 +lon_0=19.092600 +x_0=900 +y_0=900 +ellps=sphere +units=m "

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM