conv: Convert coordinates

Description Usage Arguments Details Value Author(s) See Also Examples

Description

the general function that converts lat/lon coordintes from one GCS to another GCS including WGS-84, GCJ-02 and BD-09 either locally or by calling Baidu Maps API.

Usage

1
2
conv(lat, lon, from = c("WGS-84", "GCJ-02", "BD-09"), to = c("WGS-84",
  "GCJ-02", "BD-09"), api = FALSE)

Arguments

lat

a numeric latitude

lon

a numeric longitude

from

the inputting GCS

to

the outputting GCS

api

use Baidu Maps API. Note that Baidu Maps API only supports the transformations from WGS-84 or GCJ-02 to BD-09. Other coodinate conversions must be done locally. As the conversion result is the same, it's recommended to perform conversions locally.

Details

note that the Baidu Maps API limits to 20 lat/lon coordinates per query. Since the coordinate conversion results of Baidu Maps API and local algorithms are the same, it is recommended to use local algorithms.

Value

a data.frame with variables lat/lng

Author(s)

Jun Cai (cai-j12@mails.tsinghua.edu.cn), PhD candidate from Department of Earth System Science, Tsinghua University

See Also

wgs2gcj, wgs2bd, gcj2wgs, gcj2bd, bd2wgs, bd2gcj.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: 
# latitude/longitude coordinates of Beijing railway station
# WGS-84: (39.90105, 116.42079)
# GCJ-02: (39.90245, 116.42703)
# BD-09:  (39.90851, 116.43351)
conv(39.90105, 116.42079, from = 'WGS-84', to = 'GCJ-02')
conv(39.90105, 116.42079, from = 'WGS-84', to = 'GCJ-02', api = TRUE)
conv(39.90105, 116.42079, from = 'WGS-84', to = 'BD-09')
conv(39.90105, 116.42079, from = 'WGS-84', to = 'BD-09', api = TRUE)
conv(39.90245, 116.42703, from = 'GCJ-02', to = 'WGS-84')
# not supported by baidu map api, return NAs
conv(39.90245, 116.42703, from = 'GCJ-02', to = 'WGS-84', api = TRUE)
conv(39.90245, 116.42703, from = 'GCJ-02', to = 'BD-09')
conv(39.90245, 116.42703, from = 'GCJ-02', to = 'BD-09', api = TRUE)
conv(39.90851, 116.43351, from = 'BD-09', to = 'GCJ-02')
# not supported by baidu map api, return NAs
conv(39.90851, 116.43351, from = 'BD-09', to = 'GCJ-02', api = TRUE)
conv(39.90851, 116.43351, from = 'BD-09', to = 'WGS-84')
# not supported by baidu map api, return NAs
conv(39.90851, 116.43351, from = 'BD-09', to = 'WGS-84', api = TRUE)
# convert multiple coordinates
lat = c(39.99837, 39.98565)
lng = c(116.3203, 116.2998)
conv(lat, lng, from = 'WGS-84', to = 'GCJ-02')

## End(Not run)

caijun/geoChina documentation built on May 13, 2019, 11 a.m.