2010-10-21 75 views
4

我想重新投影WGS84到基於GDA94數據的UTM投影MGA區域53的座標。我的結果是無窮大,這絕對是不正確的。我使用的r proj4包像這樣:使用R的Proj4再投影

> library(proj4) 
> df <- data.frame("x" = c(131.1, 131.102, 131.1106, 133.34), "y" = c(-13.23, -13.243, -13.22, -22.66)) 
> df 
     x  y 
1 131.1000 -13.230 
2 131.1020 -13.243 
3 131.1106 -13.220 
4 133.3400 -22.660 
> ptransform(data = df, src.proj = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", dst.proj = "+proj=utm +zone=53 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") 
$x 
[1] Inf Inf Inf Inf 

$y 
[1] Inf Inf Inf Inf 

$z 
[1] 0 0 0 0 

> 

這是怎麼回事錯在這裏?

+0

你有沒有試過沉默= F,看看是否有任何警告? – VitoshKa 2010-10-21 05:56:45

+0

我有,並且它只警告Z值,我不關心這裏。 – fmark 2010-10-21 07:14:06

回答

4

的問題是ptransform期望弧度,而不是度數。 proj4 :::項目的功能默認爲度數。如果轉換爲弧度,結果與ptransform相同。

+0

啊哈!我永遠不會想到這一點。我會試試看... – fmark 2010-10-21 11:01:46

+1

如果你看過幫助頁面,你會想到它,當事情變得絕望時,這是一個很好的計劃;) – mdsumner 2010-10-21 20:58:01

3

從哪裏得到proj4包?

嘗試rgdal如果你可以安裝它:

DF < - data.frame( 「X」= C(131.1,131.102,131.1106,133.34), 「Y」= C(-13.23,-13.243, -13.22,-22.66))

庫(rgdal)

##項目期望的矩陣,假定源是longlat/WGS84

項目(as.matrix(DF),「+ PROJ = UTM + zone = 53 + south + ellps = GRS80 + towgs84 = 0,0,0,0,0,0,0 + units = m + no_defs「)

 [,1] [,2] 

[1,] 77177.18 8534132

[2,1] 77416.79 8532695

[3,] 78310.75 8535258

[4,] 329440.68 7493165

+0

這個工程,我不知道爲什麼proj4庫沒有... – fmark 2010-10-21 07:17:32

+0

啊,我看到在CRAN proj4對不起,這裏有什麼錯 - 我會檢查出來 – mdsumner 2010-10-21 07:19:46

+0

proj4不適用於64位在Windows中,這是爲什麼我最初認爲它不在CRAN上。 – mdsumner 2010-10-21 09:50:12