【问题标题】:Easting northing to latitude longitude东向北至纬度经度
【发布时间】:2011-12-13 22:12:37
【问题描述】:

我有东/北格式的位置坐标,但我需要将其转换为适当的纬度,以便在 bing 地图中居中。任何公式或详细信息如何将东/北转换为纬度/经度?

编辑:更具体地说,我需要将 SVY21 坐标转换为 WGS84

【问题讨论】:

    标签: gps bing-maps


    【解决方案1】:

    Eastings 和 northings 分别是基点向东和向北的距离。基点通常是纬度和经度,东向和北向通常以米或英尺表示。然而,东移和北移通常会偏移一个特定的值,以使其为正值,并允许它们表示基点以西和以南的位置。

    一般来说,从一个坐标系转换到另一个坐标系并不简单,因为两者可能有不同的椭球体(地球模型)和基准面。据我了解,从一个坐标系转换到另一个坐标系的公式相当复杂。

    SVY21 但是,使用与 WGS84 完全相同的基准面和椭球体,使任务更简单。在 SVY21 中,东向和北向的基点是Base 7 at Pierce Reservoir,1 度。 22 分钟。 02.9154 秒。北纬103度。 49 分 31.9752 秒。东(即大约 1.3674765 度的纬度和大约 103.8255487 度的经度;然而,众所周知的文本分别使用 1.3666... 度和 103.8333... 度)。东距偏移量为 28001.642 米,北距偏移量为 38744.572 米。 EPSG 代码是 3414。我假设您的东向和北向以米表示。

    由于 SVY21 使用与 WGS84 相同的系统,您所要做的就是:

    • 用各自的偏移值减去东距和北距。 (数值以米为单位。)
    • 通过在给定基点、东向绝对值以及东向正向时的 90 度或负向时的 270 度方位角的情况下查找目标点来查找给定点的经度。这种计算称为求解“直接测地线问题”,这在 C.F.F. Karney 的文章“Algorithms for geodesics, 2012.
    • 通过查找给定基点的目标点、北距的绝对值以及北距为正时的 0 度或负时为 180 度的方位来找到给定点的纬度。

    【讨论】:

    • 你指的是Haversine的公式吗?从东/北到纬度/经度怎么样?
    • 不,我指的是余弦的球面定律,尽管它也可能适用于文森蒂的直接公式。
    【解决方案2】:

    我已将 Javascript 实现转换为 T-SQL 函数,用于 WGS84 到纬度/经度值。随意使用您认为合适的。如果您需要不同的坐标系,请查看我用作来源的威斯康星大学 - 绿湾网页并获取更新后的常量。

        drop function UF_utm_to_lat
    go
    create function UF_utm_to_lat(@utmz float, @x float, @y float) returns float
    as
    begin
        --Based on code from this page: http://www.uwgb.edu/dutchs/usefuldata/ConvertUTMNoOZ.HTM
        declare @latitude float;
        declare @longitude float;
        set @latitude = 0.00;
        set @longitude = 0.00;
    
        --Declarations
        declare @a float;
        declare @f float;
        declare @drad float;
        declare @k0 float;
        declare @b float;
        declare @e float;
        declare @e0 float;
        declare @esq float;
        declare @e0sq float;
        declare @zcm float;
        declare @e1 float;
        declare @M float;
        declare @mu float;
        declare @phi1 float;
        declare @C1 float;
        declare @T1 float;
        declare @N1 float;
        declare @R1 float;
        declare @D float;
        declare @phi float;
        declare @lng float;
        declare @lngd float;
    
        --Datum Info here: Name, a, b, f, 1/f
        --WGS 84    6,378,137.0 6356752.314 0.003352811 298.2572236
    
        set @a = 6378137.0;
        set @b = 6356752.314;
        set @f = 0.003352811;
        set @drad = PI()/180.0;
        set @k0 = 0.9996; --scale on central meridian
    
        set @e = SQRT(1.0 - (@b/@a)*(@b/@a)); --Eccentricity
        --e = Math.sqrt(1 - (b/a)*(b/a));//eccentricity
        set @e0 = @e/SQRT(1.0 - @e*@e); --Called e prime in reference
        --e0 = e/Math.sqrt(1 - e*e);//Called e prime in reference
        set @esq = (1.0 - (@b/@a)*(@b/@a)); --e squared for use in expansions
        --esq = (1 - (b/a)*(b/a));//e squared for use in expansions
        set @e0sq = @e*@e/(1.0-@e*@e); --e0 squared - always even powers
        --e0sq = e*e/(1-e*e);// e0 squared - always even powers
        set @zcm = 3.0 + 6.0*(@utmz-1.0) - 180.0; --Central meridian of zone
        --zcm = 3 + 6*(utmz-1) - 180;//Central meridian of zone
        set @e1 = (1.0 - SQRT(1.0 - @e*@e))/(1.0 + SQRT(1.0 - @e*@e)); --Called e1 in USGS PP 1395 also
        --e1 = (1 - Math.sqrt(1 - e*e))/(1 + Math.sqrt(1 - e*e));//Called e1 in USGS PP 1395 also
        set @M = 0.0 + @y / @k0; --Arc length along standard meridian
        --M = M0 + y/k0;//Arc length along standard meridian. 
        set @mu = @M/(@a*(1.0 - @esq*(1.0/4.0 + @esq*(3.0/64.0 + 5.0*@esq/256.0))));
        --mu = M/(a*(1 - esq*(1/4 + esq*(3/64 + 5*esq/256))));
        set @phi1 = @mu + @e1*(3.0/2.0 - 27.0*@e1*@e1/32.0)*SIN(2.0*@mu) + @e1*@e1*(21.0/16.0 - 55.0*@e1*@e1/32.0)*SIN(4.0*@mu); --Footprint Latitude
        --phi1 = mu + e1*(3/2 - 27*e1*e1/32)*Math.sin(2*mu) + e1*e1*(21/16 -55*e1*e1/32)*Math.sin(4*mu);//Footprint Latitude
        set @phi1 = @phi1 + @e1*@e1*@e1*(SIN(6.0*@mu)*151.0/96.0 + @e1*SIN(8.0*@mu)*1097.0/512.0);
        --phi1 = phi1 + e1*e1*e1*(Math.sin(6*mu)*151/96 + e1*Math.sin(8*mu)*1097/512);
        set @C1 = @e0sq*POWER(COS(@phi1),2.0);
        --C1 = e0sq*Math.pow(Math.cos(phi1),2);
        set @T1 = POWER(TAN(@phi1),2.0);
        --T1 = Math.pow(Math.tan(phi1),2);
        set @N1 = @a/SQRT(1.0-POWER(@e*SIN(@phi1),2.0));
        --N1 = a/Math.sqrt(1-Math.pow(e*Math.sin(phi1),2));
        set @R1 = @N1*(1.0-@e*@e)/(1.0-POWER(@e*SIN(@phi1),2.0));
        --R1 = N1*(1-e*e)/(1-Math.pow(e*Math.sin(phi1),2));
        set @D = (@x-500000.0)/(@N1*@k0);
        --D = (x-500000)/(N1*k0);
        set @phi = (@D*@D)*(1.0/2.0 - @D*@D*(5.0 + 3.0*@T1 + 10.0*@C1 - 4.0*@C1*@C1 - 9.0*@e0sq)/24.0);
        --phi = (D*D)*(1/2 - D*D*(5 + 3*T1 + 10*C1 - 4*C1*C1 - 9*e0sq)/24);
        set @phi = @phi + POWER(@D,6.0)*(61.0 + 90.0*@T1 + 298.0*@C1 + 45.0*@T1*@T1 - 252.0*@e0sq - 3.0*@C1*@C1)/720.0;
        --phi = phi + Math.pow(D,6)*(61 + 90*T1 + 298*C1 + 45*T1*T1 -252*e0sq - 3*C1*C1)/720;
        set @phi = @phi1 - (@N1*TAN(@phi1)/@R1)*@phi;
        --phi = phi1 - (N1*Math.tan(phi1)/R1)*phi;
    
    
        set @latitude = FLOOR(1000000.0*@phi/@drad)/1000000.0;
    
        set @lng = @D*(1.0 + @D*@D*((-1.0 - 2.0*@T1 - @C1)/6.0 + @D*@D*(5.0 - 2.0*@C1 + 28.0*@T1 - 3.0*@C1*@C1 + 8.0*@e0sq + 24.0*@T1*@T1)/120))/COS(@phi1);
        set @lngd = @zcm+@lng/@drad;
        set @longitude = FLOOR(1000000.0*@lngd)/1000000.0;
    
    
        return @latitude;
    end
    go
    drop function UF_utm_to_long
    go
    create function UF_utm_to_long(@utmz float, @x float, @y float) returns float
    as
    begin
        --Based on code from this page: http://www.uwgb.edu/dutchs/usefuldata/ConvertUTMNoOZ.HTM
        declare @latitude float;
        declare @longitude float;
        set @latitude = 0.00;
        set @longitude = 0.00;
    
        --Declarations
        declare @a float;
        declare @f float;
        declare @drad float;
        declare @k0 float;
        declare @b float;
        declare @e float;
        declare @e0 float;
        declare @esq float;
        declare @e0sq float;
        declare @zcm float;
        declare @e1 float;
        declare @M float;
        declare @mu float;
        declare @phi1 float;
        declare @C1 float;
        declare @T1 float;
        declare @N1 float;
        declare @R1 float;
        declare @D float;
        declare @phi float;
        declare @lng float;
        declare @lngd float;
    
        --Datum Info here: Name, a, b, f, 1/f
        --WGS 84    6,378,137.0 6356752.314 0.003352811 298.2572236
    
        set @a = 6378137.0;
        set @b = 6356752.314;
        set @f = 0.003352811;
        set @drad = PI()/180.0;
        set @k0 = 0.9996; --scale on central meridian
    
        set @e = SQRT(1.0 - (@b/@a)*(@b/@a)); --Eccentricity
        --e = Math.sqrt(1 - (b/a)*(b/a));//eccentricity
        set @e0 = @e/SQRT(1.0 - @e*@e); --Called e prime in reference
        --e0 = e/Math.sqrt(1 - e*e);//Called e prime in reference
        set @esq = (1.0 - (@b/@a)*(@b/@a)); --e squared for use in expansions
        --esq = (1 - (b/a)*(b/a));//e squared for use in expansions
        set @e0sq = @e*@e/(1.0-@e*@e); --e0 squared - always even powers
        --e0sq = e*e/(1-e*e);// e0 squared - always even powers
        set @zcm = 3.0 + 6.0*(@utmz-1.0) - 180.0; --Central meridian of zone
        --zcm = 3 + 6*(utmz-1) - 180;//Central meridian of zone
        set @e1 = (1.0 - SQRT(1.0 - @e*@e))/(1.0 + SQRT(1.0 - @e*@e)); --Called e1 in USGS PP 1395 also
        --e1 = (1 - Math.sqrt(1 - e*e))/(1 + Math.sqrt(1 - e*e));//Called e1 in USGS PP 1395 also
        set @M = 0.0 + @y / @k0; --Arc length along standard meridian
        --M = M0 + y/k0;//Arc length along standard meridian. 
        set @mu = @M/(@a*(1.0 - @esq*(1.0/4.0 + @esq*(3.0/64.0 + 5.0*@esq/256.0))));
        --mu = M/(a*(1 - esq*(1/4 + esq*(3/64 + 5*esq/256))));
        set @phi1 = @mu + @e1*(3.0/2.0 - 27.0*@e1*@e1/32.0)*SIN(2.0*@mu) + @e1*@e1*(21.0/16.0 - 55.0*@e1*@e1/32.0)*SIN(4.0*@mu); --Footprint Latitude
        --phi1 = mu + e1*(3/2 - 27*e1*e1/32)*Math.sin(2*mu) + e1*e1*(21/16 -55*e1*e1/32)*Math.sin(4*mu);//Footprint Latitude
        set @phi1 = @phi1 + @e1*@e1*@e1*(SIN(6.0*@mu)*151.0/96.0 + @e1*SIN(8.0*@mu)*1097.0/512.0);
        --phi1 = phi1 + e1*e1*e1*(Math.sin(6*mu)*151/96 + e1*Math.sin(8*mu)*1097/512);
        set @C1 = @e0sq*POWER(COS(@phi1),2.0);
        --C1 = e0sq*Math.pow(Math.cos(phi1),2);
        set @T1 = POWER(TAN(@phi1),2.0);
        --T1 = Math.pow(Math.tan(phi1),2);
        set @N1 = @a/SQRT(1.0-POWER(@e*SIN(@phi1),2.0));
        --N1 = a/Math.sqrt(1-Math.pow(e*Math.sin(phi1),2));
        set @R1 = @N1*(1.0-@e*@e)/(1.0-POWER(@e*SIN(@phi1),2.0));
        --R1 = N1*(1-e*e)/(1-Math.pow(e*Math.sin(phi1),2));
        set @D = (@x-500000.0)/(@N1*@k0);
        --D = (x-500000)/(N1*k0);
        set @phi = (@D*@D)*(1.0/2.0 - @D*@D*(5.0 + 3.0*@T1 + 10.0*@C1 - 4.0*@C1*@C1 - 9.0*@e0sq)/24.0);
        --phi = (D*D)*(1/2 - D*D*(5 + 3*T1 + 10*C1 - 4*C1*C1 - 9*e0sq)/24);
        set @phi = @phi + POWER(@D,6.0)*(61.0 + 90.0*@T1 + 298.0*@C1 + 45.0*@T1*@T1 - 252.0*@e0sq - 3.0*@C1*@C1)/720.0;
        --phi = phi + Math.pow(D,6)*(61 + 90*T1 + 298*C1 + 45*T1*T1 -252*e0sq - 3*C1*C1)/720;
        set @phi = @phi1 - (@N1*TAN(@phi1)/@R1)*@phi;
        --phi = phi1 - (N1*Math.tan(phi1)/R1)*phi;
    
        set @latitude = FLOOR(1000000.0*@phi/@drad)/1000000.0;
    
        set @lng = @D*(1.0 + @D*@D*((-1.0 - 2.0*@T1 - @C1)/6.0 + @D*@D*(5.0 - 2.0*@C1 + 28.0*@T1 - 3.0*@C1*@C1 + 8.0*@e0sq + 24.0*@T1*@T1)/120))/COS(@phi1);
        set @lngd = @zcm+@lng/@drad;
        set @longitude = FLOOR(1000000.0*@lngd)/1000000.0;
    
    
        return @longitude;
    end
    

    【讨论】:

      【解决方案3】:

      perl中有一个比较简单的解决方案:

      所以,首先,请确保您已安装 Perl。然后,安装 以下四个模块:

      Geo::HelmertTransform Geography::NationalGrid CAM::DBF mySociety::GeoUtil

      您可以通过多种方式做到这一点。我是这样做的:

      # Geo::HelmertTransform 
      wget http://search.cpan.org/CPAN/authors/id/M/MY/MYSOCIETY/Geo-HelmertTransform-1.13.tar.gz 
      tar xzf Geo-HelmertTransform-1.13.tar.gz  
      perl Makefile.PL 
      make 
      make install
      
      # Geography::NationalGrid 
      http://search.cpan.org/CPAN/authors/id/P/PK/PKENT/Geography-NationalGrid-1.6.tar.gz 
      tar xzf Geography-NationalGrid-1.6.tar.gz 
      perl Makefile.PL 
      make 
      make install
      
      # CAM::DBF 
      wget http://search.cpan.org/CPAN/authors/id/C/CL/CLOTHO/CAM-DBF-1.02.tgz 
      tar xzf CAM-DBF-1.02.tgz 
      perl Makefile.PL 
      make 
      make install
      
      # mySociety::GeoUtil
      # See: http://parlvid.mysociety.org:81/os/ -> https://github.com/mysociety/commonlib/blob/master/perllib/mySociety/GeoUtil.pm
      mkdir -p mySociety 
      wget -O mySociety/GeoUtil.pm 'https://raw.githubusercontent.com/mysociety/commonlib/master/perllib/mySociety/GeoUtil.pm'
      
      1. 获取 GB 数据。

      点击此处下载英国“Code-Point® Open”数据集 并按照说明进行操作。下载 codepo_gb.zip 后 您可以按如下方式提取它:

      解压代码po_gb.zip

      假设解压后的文件现在在当前目录下, 然后,您可以运行以下 perlscript 以解析数据, 提取 GB 东向/北向并将它们转换为 纬度/经度。

      use strict;
      use mySociety::GeoUtil qw/national_grid_to_wgs84/;
      
      while (<>) {
          my @x=split(/,/); # split csv
          my ($pc, $east, $north) = ($x[0], $x[10], $x[11]);
          $pc=~s/\"//g; # remove quotes around postcode
          my ($lat, $lng) = national_grid_to_wgs84($east, $north, "G"); # "G" means Great Britain
          print "$pc,$lat,$lng\n";
      }
      

      (要调用,将最后一个代码块保存到.pl文件中,然后调用perl script.pl your.csv ...还要记住,$x[0]、$x[10]和$x[11]应该是邮政编码、东距和北距的列号。

      感谢http://baroque.posterous.com/uk-postcode-latitudelongitude

      【讨论】:

      • 会很好,但我更喜欢用于便携性转换的计算和/或公式。其次,svy21是新加坡的,所以英国的SVY到WGS84的转换不适用。
      • 我的错,希望它能对某人有所帮助,因为我在急于寻找解决方案时偶然发现了这个问题,这是英国转换的最简单方法。
      • 真的。这就是为什么我没有投反对票,因为有人可能也会觉得这很有用。
      • 这对我来说非常有用,因为我需要将一些英国巴士站位置转换为 WGS84 东/北。可惜我只能投 1 票——你省去了将我发现的 JavaScript 算法移植到 Perl 中的工作!!
      【解决方案4】:

      有数百种不同的坐标系 - 东/北和纬度/经度是坐标的类型,但它们不足以唯一标识获得这些坐标的系统。 p>

      您需要有一个 EPSG 代码(例如 4326、4269、27700、32701)或空间参考系统的详细信息(基准面、投影、本初子午线和测量单位)。选择的目标格式。 您在问题标题中提到“GPS”,所以我假设您需要的纬度/经度是相对于全球定位系统使用的 WGS84 基准定义的,但是该基准仍有许多预测可能导致不同的东移/北移值。

      获得所用投影的详细信息后,您可以使用 Proj.4 库 (http://trac.osgeo.org/proj/) 之类的代码在代码中执行转换

      【讨论】:

      • 我得到的结果是 SVY21 格式,我需要将其转换为 WGS84 并将其绘制在 bing 地图中。使用图书馆可以吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-21
      • 2020-09-13
      • 2019-01-23
      • 2016-10-09
      • 1970-01-01
      相关资源
      最近更新 更多