convCoord: Generic Function to Convert coordinates

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

View source: R/geoCoord.R

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
convCoord(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 2-col data.frame ([lng, lat]) of transformed coordinates.

Author(s)

Jun Cai (cai-j12@mails.tsinghua.edu.cn), PhD student from Center for Earth System Science, Tsinghua University

See Also

convWGS2GCJ, convWGS2BD, convGCJ2WGS, convGCJ2BD, convBD2WGS, convBD2GCJ.

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)
convCoord(39.90105, 116.42079, from = 'WGS-84', to = 'GCJ-02')
convCoord(39.90105, 116.42079, from = 'WGS-84', to = 'GCJ-02', api = TRUE)
convCoord(39.90105, 116.42079, from = 'WGS-84', to = 'BD-09')
convCoord(39.90105, 116.42079, from = 'WGS-84', to = 'BD-09', api = TRUE)
convCoord(39.90245, 116.42703, from = 'GCJ-02', to = 'WGS-84')
# not supported by baidu map api, return NAs
convCoord(39.90245, 116.42703, from = 'GCJ-02', to = 'WGS-84', api = TRUE)
convCoord(39.90245, 116.42703, from = 'GCJ-02', to = 'BD-09')
convCoord(39.90245, 116.42703, from = 'GCJ-02', to = 'BD-09', api = TRUE)
convCoord(39.90851, 116.43351, from = 'BD-09', to = 'GCJ-02')
# not supported by baidu map api, return NAs
convCoord(39.90851, 116.43351, from = 'BD-09', to = 'GCJ-02', api = TRUE)
convCoord(39.90851, 116.43351, from = 'BD-09', to = 'WGS-84')
# not supported by baidu map api, return NAs
convCoord(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)
convCoord(lat, lng, from = 'WGS-84', to = 'GCJ-02')

## End(Not run)

madlogos/recharts2 documentation built on May 21, 2019, 11:03 a.m.