oracle操作之经纬度转换

本文介绍了如何在Oracle数据库中进行经纬度的度分秒与点度之间的转换操作,提供了具体的SQL更新语句示例,便于对地理坐标数据进行处理。

一、度分秒转点度

select t.lon,substr(t.lon,0,instr(t.lon,'°')-1) ,
substr(t.lon,instr(t.lon,'°')+1,instr(t.lon,'′')-instr(t.lon,'°')-1) ,
substr(t.lon,instr(t.lon,'′')+1,instr(t.lon,'″')-instr(t.lon,'′')-1) from mtr_wprd_station t;  
 
select t.lat,substr(t.lat,0,instr(t.lat,'°')-1) ,
substr(t.lat,instr(t.lat,'°')+1,instr(t.lat,'′')-instr(t.lat,'°')-1) ,
substr(t.lat,instr(t.lat,'′')+1,instr(t.lat,'″')-instr(t.lat,'′')-1) from mtr_wprd_station t; 
 
update mtr_wprd_station t set t.lon_decimal= substr(t.lon,0,instr(t.lon,'°')-1)
+substr(t.lon,instr(t.lon,'°')+1,instr(t.lon,'′')-instr(t.lon,'°')-1)/60
+substr(t.lon,instr(t.lon,'′')+1,instr(t.lon,'″')-instr(t.lon,'′')-1)/3600;

update mtr_wprd_station t set t.lat_decimal= substr(t.lat,0,instr(t.lat,'°')-1)
+substr(t.lat,instr(t.lat,'°')+1,instr(t.lat,'′')-instr(t.lat,'°')-1)/60
+substr(t.lat,instr(t.lat,'′')+1,instr(t.lat,'″')-instr(t.lat,'′')-1)/3600;

select t.lon_decimal from mtr_wprd_station t;
select t.lat_decimal from mtr_wprd_station t;


二、点度转度分秒

update STT_ASM_STATION_TMP_201503 t
   set t.lon1 = trunc(t.lon),
       t.lon2 = trunc((t.lon - trunc(t.lon)) * 60),
       t.lon3 = trunc(((t.lon - trunc(t.lon)) * 60 - trunc((t.lon - trunc(t.lon)) * 60)) * 60);

update STT_ASM_STATION_TMP_201503 t
   set t.lat1 = trunc(t.lat),
       t.lat2 = trunc((t.lat - trunc(t.lat)) * 60),
       t.lat3 = trunc(((t.lat - trunc(t.lat)) * 60 - trunc((t.lat - trunc(t.lat)) * 60)) * 60);








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值