Learn R Programming

geoChina (version 1.3.0)

wgs2gcj: Convert coordinates

Description

converts lat/lon coordintes from WGS-84 to GCJ-02

Usage

wgs2gcj(wgsLat, wgsLon)

Arguments

wgsLat
a numeric latitude in WGS-84
wgsLon
a numeric longitude in WGS-84

Value

a data.frame with variables lat/lng

Details

All real WGS-84 latitude/longitude coordites must be encrypted by National Admistration of Surveying, Mapping and Geoinformation (http://en.sbsm.gov.cn/) into GCJ-02 (known as 'Mars coordinate system') with a deviation no more than 700 meters in China. The decryption algorithm is a public secrect on the Internet and verfied to be correct.

See Also

gcj2wgs, conv. https://on4wp7.codeplex.com/SourceControl/changeset/view/21483#353936 for C version source code.

Examples

Run this code
## Not run: ------------------------------------
# # latitude/longitude coordinates of Beijing railway station
# # WGS-84: (39.90105, 116.42079)
# # GCJ-02: (39.90245, 116.42703)
# wgs2gcj(39.90105, 116.42079) # correct
# # convert multiple coordinates
# wgs2gcj(c(39.99837, 39.98565), c(116.3203, 116.2998))
## ---------------------------------------------

Run the code above in your browser using DataLab