WGS84 to GCJ02, GCJ02 to BD09 and vice versa. WG84 is used by Google maps and hardware, GCJ02 is used by Gaode and Tencent, BD09 is used by Baidu.

wgs2gcj(wgs_lon, wgs_lat)

gcj2wgs(gcj_lon, gcj_lat)

gcj2bd(gcj_lon, gcj_lat)

bd2gcj(bd_lon, bd_lat)

wgs2bd(wgs_lon, wgs_lat)

bd2wgs(bd_lon, bd_lat)

Arguments

wgs_lon

WGS84 longitude

wgs_lat

WGS84 latitude

gcj_lon

GCJ02 longitude, gaode/tencent

gcj_lat

GCJ02 latitude, gaode/tencent

bd_lon

BD09 longitude, baidu map

bd_lat

BD09 latitude, baidu map

Value

Transformed vector of longitude and latitude.

Examples

test <- structure( list( startLon = c( 113.58850000000001, 113.54700000000003, 113.54050000000001, 113.52866660000001, 113.53083329999998, 113.54083329999997 ), startLat = c( 33.43299999999999, 33.466666599999996, 33.49250000000001, 33.4581666, 33.45766660000001, 33.49250000000001 ), endLon = c( 113.5468333, 113.54050000000001, 113.52866660000001, 113.53083329999998, 113.54083329999997, 113.52249999999998 ), endLat = c( 33.465, 33.49250000000001, 33.4581666, 33.457166599999994, 33.49233330000001, 33.49250000000001 ) ), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame") ) wgs_lon <- test$startLon[[1]] wgs_lat <- test$startLat[[1]] wgs2gcj(wgs_lon, wgs_lat)# gaode
#> [1] 113.59441 33.43121
wgs2bd(wgs_lon, wgs_lat)#baidu
#> [1] 113.60098 33.43695
t(apply(test, 1, function(x) { start_gps <- wgs2bd(x[1], x[2]) end_gps <- wgs2bd(x[3], x[4]) c(start_gps, end_gps) }))
#> [,1] [,2] [,3] [,4] #> [1,] 113.6010 33.43695 113.5593 33.46922 #> [2,] 113.5595 33.47089 113.5530 33.49687 #> [3,] 113.5530 33.49687 113.5411 33.46272 #> [4,] 113.5411 33.46272 113.5433 33.46169 #> [5,] 113.5433 33.46219 113.5533 33.49669 #> [6,] 113.5533 33.49686 113.5350 33.49716