[转载]:经纬度与WGS84坐标转换
本代码实现在WGS84系统的大地坐标(BLH)和空间直角坐标(XYZ)的互相转换,符合标准语法,可直接使用
如下代码,输出为:
WGS84: -2175790.73969891 4461032.11207734 3992337.79032463
BLH: 38.9999999999998 116.000000000000 33.0000069718808
Module CorrTrans
!// WGS84 系统BLH坐标与空间直角坐标转换
!// Fortran Coder http://fcode.cn
!// Adapted from Acheng's C++ code
Implicit None
Integer , parameter :: DP = Selected_Real_Kind( 12 )
Real(kind=DP) , parameter :: PI = 3.14159265358979323846_DP
Real(kind=DP) , parameter , private :: a = 6378137._DP
Real(kind=DP) , parameter , private :: f = 1.0_DP / 298.257223563_DP
Real(kind=DP) , parameter , private :: t = a * ( 1.0_DP - f )
Real(kind=DP) , parameter , private :: e = sqrt( (a*a - t*t) / (a*a) )
contains
Subroutine XYZ2BLH( x , y , z , B , L , H )
Real(Kind=DP) , Intent( IN ) :: x , y , z
Real(Kind=DP) , Intent( OUT ) :: B , L , H
real(kind=DP) :: N
integer :: i
L = atan( abs(y/x) )
B = atan( abs(z/sqrt(x*x+y*y) ) )
do i = 1 , 5
N = a / sqrt( 1.0_DP - e*e*sin(B)*sin(B) )
H = z / sin(B) - N * ( 1.0_DP - e*e )
B = atan( z*(N+H) / ( sqrt(x*x+y*y)*(N*(1.0_DP-e*e)+H) ) )
end do
if ( x < 0._DP .and. y > 0._DP ) L = PI - L
if ( x > 0._DP .and. y < 0._DP ) L = -1.0_DP * L
if ( x < 0._DP .and. y < 0._DP ) L = -1.0 * PI + L
B = B * 180._DP / PI
L = L * 180._DP / PI
End Subroutine XYZ2BLH Subroutine BLH2XYZ( B , L , H , x , y , z )
Real(Kind=DP) , Intent( IN ) :: B , L , H
Real(Kind=DP) , Intent( OUT ) :: x , y , z
real(kind=DP) :: N , Br , Lr
Br = B * PI / 180._DP
Lr = L * PI / 180._DP
N = a / sqrt( 1.0_DP - e*e*sin(Br)*sin(Br) )
x = ( N + H ) * cos(Br)*cos(Lr)
y = ( N + H ) * cos(Br)*sin(Lr)
z = ( N*(1.0_DP - e*e ) + H ) * sin(Br);
End Subroutine BLH2XYZ End Module CorrTrans Program www_fcode_cn
Use CorrTrans
Implicit None
Real(Kind=DP) :: x , y , z
Real(Kind=DP) :: B , L , H
B = 39._DP ; L = 116._DP ; H = 33._DP
call BLH2XYZ( B , L , H , x , y , z )
write(*,*) 'WGS84:' , x , y , z
call XYZ2BLH( x , y , z , B , L , H )
write(*,*) 'BLH:' , B , L , H
End Program www_fcode_cn
转自:http://fcode.cn/code_prof-89-1.html
[转载]:经纬度与WGS84坐标转换的更多相关文章
- 火星坐标、百度坐标、WGS84坐标转换代码(JS、python版)
火星坐标.百度坐标.WGS84坐标转换代码(JS.python版) 一.JS版本源码 github:https://github.com/wandergis/coordTransform /** * ...
- 火星坐标、百度坐标、WGS84坐标转换代码(JS)
JS版本源码 /** * Created by Wandergis on 2015/7/8. * 提供了百度坐标(BD09).国测局坐标(火星坐标,GCJ02).和WGS84坐标系之间的转换 */ / ...
- C# UTM坐标和WGS84坐标转换小工具
工具根据:http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html js代码改编 工具源码github:https://github. ...
- WGS84,GCJ02, BD09坐标转换
public class Gps { private double wgLat; private double wgLon; public Gps(double wgLat, double wgLon ...
- python 编写的经纬度坐标转换类
# -*- coding: utf-8 -*- # /** # * 各地图API坐标系统比较与转换; # * WGS84坐标系:即地球坐标系,国际上通用的坐标系.设备一般包含GPS芯片或者北斗芯片获取 ...
- 简谈百度坐标反转至WGS84的三种思路
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 基于百度地图进行数据展示是目前项目中常见场景,但是因为百度地图 ...
- IDL通过经纬度定位获取DN值
以前就想写,但是因为envi可以就一直没弄.今天正好有个机会,就做了这个事情.ENVI中在主窗口中pixel locator可以实现,但是当我们需要读入很多的数据的时候,也就是批量处理的时候,显然编程 ...
- WGS84、GCJ-02(火星坐标)、百度坐标,Web墨卡托坐标
GCJ-02坐标系统(火星坐标)简介:http://blog.csdn.net/giswens/article/details/8775121(存档:http://mapbd.com/cms/2012 ...
- BD09坐标(百度坐标) WGS84(GPS坐标) GCJ02(国测局坐标) 的相互转换
BD09坐标(百度坐标) WGS84(GPS坐标) GCJ02(国测局坐标) 的相互转换 http://www.cnphp6.com/archives/24822 by root ⋅ Leave a ...
随机推荐
- java的eclipse操作和常用类Object的使用
1.eclipse的快捷键: (1)alt + / 内容辅助. 如:main+alt + / 会出现完整的main方法. syso+alt+ / 会输出. 如编写某个方法时,只需写入方法名 + a ...
- js 上传文件预览
1. FILE API html5提供了FIle和FileReader两个方法,可以读取文件信息并读取文件. 2. example <html> <body> <div ...
- 【Python】实现5!+4!+3!+2!+1!
#!/usr/bin/env python #-*- coding:utf-8 -*- def factorial_add(n): empty_list=[] #定义一个空列表 for i in ma ...
- Unity UGUI RectTransform图解
UGUI RectTransform.Unity RectTransform详解 The first:look look API. http://docs.unity3d.com/ScriptRefe ...
- linux系统io的copy
#include<stdio.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h&g ...
- ubuntu下mysql的常用命令,MySQL数据库的基本操作命令
一.mysql服务操作 0.查看数据库版本 sql-> status; 1.net start mysql //启动mysql服务 2.net stop mysql //停止mysql服务 3 ...
- 【Jenkins】jenkins简单搭建并执行任务
part 1 jenkins用户名的配置(gerrit 2.11) #安装jenkins $ sudo apt-get install jenkins #为jenkins用户设定密码 $ sudo ...
- iOS9适配中的各种问题
1.http在ios9上不能在使用.需要进行配置. the resource could not be loaded because the app transport security policy ...
- VC_MFC水波纹控件,开源
代码和效果图: https://github.com/wjx0912/MfcWaterEffect 集成以下5个文件即可: watereffect\DIB.hwatereffect\DIB.cppwa ...
- powerdsigner java对象模型将中文name生成在注释中
[\n]\ @Title [%Name%\n\n]\ 遗憾的是保存这个配置会出错,每次软件启动后要重新配置. 生成出来的字段样式: /** * 评论时间 * * @pdOid bd8ec6fd-5cb ...