2017-11-08 8 views
0

タイル番号をEPSG:3395のlon./lagに変換する必要がありますが、解決策が見つかりません。タイル番号をlon./latに設定します。 EPSG:3395

私はcode for EPSG:4326を見つけましたが、EPSG:3395に適合させる方法が見つかりません。

4326のコード(それがうまく機能):

$n = pow(2, $zoom); 
$lon_deg = $xtile/$n * 360.0 - 180.0; 
$lat_deg = rad2deg(atan(sinh(pi() * (1 - 2 * $ytile/$n)))); 

私はEPSGでlon./lagへのタイルの数を変換する必要があります:3395しかし、私は実用的なソリューションを見つけることができません。私はthis answerに基づいていくつかのコードを実装しました。

私は3395度に4326度を変換しようとしました

def getVal(x, y, n): 
    lon_deg = x/n * 360.0 - 180.0 
    lat_rad = math.atan(math.sinh(math.pi * (1 - 2 * y/n))) 
    lat_deg = math.degrees(lat_rad) 
    #Convert in 3395 
    a = 6378137 #WGS84 semi-major axis 
    b = 6356752.3142 #WGS84 semi-minor axis 
    print(math.sqrt(1 - b^2/a^2)) 
    e = math.sqrt(1 - b^2/a^2) #ellipsoid eccentricity 
    c = math.pow((1 - e*math.sin(latitude))/(1 + e*math.sin(latitude)), e/2) 
    lat_deg = a * ln(math.tan(math.pi/4 + lat_deg/2) * c) 
    lon_deg = a * lon_deg; 

私は、次のエラーメッセージ取得:

Unsupported operand type(s) for float and INT 

更新:私は置き換えることにより、以下のコードに修正しました^ **で。

コード:

def getVal(x, y, n): 
     #Calcuate coordinates in 4326 
     lon_deg = x/n * 360.0 - 180.0 
     lat_rad = math.atan(math.sinh(math.pi * (1 - 2 * y/n))) 
     lat_deg = math.degrees(lat_rad) 
     #Convert coordinates in 3395 
     a = 6378137 #WGS84 semi-major axis 
     b = 6356752.3142 #WGS84 semi-minor axis 
     e = math.sqrt(1 - b**2/a**2) #ellipsoid eccentricity 
     c = math.pow((1 - e*math.sin(lat_deg))/(1 + e*math.sin(lat_deg)), e/2) 
     lon_deg = a * lon_deg; 
     lat_deg = a * math.log(math.tan(math.radians(math.pi/4 + lat_deg/2) * c)) 

しかし、まだ投影が奇妙です。 私はこの問題は、この部分にあると仮定します。

 lat_deg = a * math.log(math.tan(math.radians(math.pi/4 + lat_deg/2) 

math.tanは度の角度を好きではないと私はmath.radiansを挿入しなければなりませんでした。

+0

これはhttps://gis.stackexchange.com/questions/259121/transformation-functions-for-epsg3395-projection-vs-epsg3857 – Radan

+0

おかげで、私は私を更新した – neonepthys

答えて

0

座標をEPSG:3395に変換する数式を知りたいかのように見えます。これがこの質問の正しい場所であるかどうかはわかりませんが、helpかもしれません。

電源をオンにしようとすると、オペランド** not ^が使用されます。

def getVal(x, y, n): 
    lon_deg = x/n * 360.0 - 180.0 
    lat_rad = math.atan(math.sinh(math.pi * (1 - 2 * y/n))) 
    lat_deg = math.degrees(lat_rad) 
    #Convert in 3395 
    a = 6378137 #WGS84 semi-major axis 
    b = 6356752.3142 #WGS84 semi-minor axis 
    print(math.sqrt(1 - b**2/a**2)) 
    e = math.sqrt(1 - b**2/a**2) #ellipsoid eccentricity 
    c = math.pow((1 - e*math.sin(latitude))/(1 + e*math.sin(latitude)), e/2) 
    lat_deg = a * ln(math.tan(math.pi/4 + lat_deg/2) * c) 
    lon_deg = a * lon_deg; 
+0

おかげで私の要求を更新しているに役立つかもしれませんリクエスト – neonepthys

+0

私は問題がパワーオペランドであったと思います。私は自分の答えを更新しました。 :)私は助けて願っています。乾杯。 ref https://stackoverflow.com/questions/34258537/python-typeerror-unsupported-operand-types-for-float-and-int – Radan

+0

IDは、ありがとう、しかし私は別の問題があります。私は私の要求を更新しました。 – neonepthys

関連する問題