我有东方/北方格式的位置坐标,但我需要将其转换为适当的纬度,以便将其置于bing地图中。任何公式或细节如何将东/北转换为纬度/经度?
编辑:更具体地说,我需要将SVY21坐标转换为WGS84
答案 0 :(得分:14)
通常,从一个坐标系转换到另一个坐标系并不简单,因为它们可能具有不同的椭球(地球模型)和基准面。据我所知,从一个坐标系转换到另一个坐标系的公式相当复杂。
然而,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相同的系统,您所要做的就是:
答案 1 :(得分:3)
有数百种不同的坐标系 - Easting / Northing和Lat / Long是坐标的类型,但它们不足以唯一地识别从中获取这些坐标的系统。
你需要有一个EPSG代码(例如4326,4269,27700,32701),或者你需要的源代码和空间参考系统的细节(基准面,投影,本初子午线和测量单位)。选择目的地格式。 你在问题标题中提到“GPS”,所以我假设你需要的纬度/经度是相对于全球定位系统使用的WGS84数据来定义的,但是仍然有许多可能导致不同东方的数据的预测/北方价值观。
一旦获得了所使用的投影的详细信息,就可以使用类似Proj.4库(http://trac.osgeo.org/proj/)的代码执行代码转换
答案 2 :(得分:2)
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'
- 获取GB数据。
醇>点击此处下载英国“Code-Point®Open”数据集 并按照说明操作。一旦你下载了codepo_gb.zip 你可以按如下方式提取它:
解压缩codepo_gb.zip
假设解压缩的文件现在位于当前目录中, 然后你可以运行以下perlscript来解析数据, 提取GB eastings / northings并将它们转换为 纬度/经度。
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
答案 3 :(得分:2)
我已将Javascript实现转换为WGS84到纬度/经度值的T-SQL函数。随意使用你认为合适的。如果您需要不同的坐标系,请查看我用作源的威斯康星大学 - 格林湾网页,并获取更新的常数。
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