Learn R Programming

geoChina (version 1.3.0)

gcj2wgs: Convert coordinates

Description

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

Usage

gcj2wgs(gcjLat, gcjLon)

Arguments

gcjLat
a numeric latitude in GCJ-02
gcjLon
a numeric longitude in GCJ-02

Value

a data.frame with variables lat/lng

Details

since the encryption function from WGS-84 to GCJ-02 doesn't have inverse function, the inverse transformation can only be achieved by numeric algorithm. Coordinates encryption algorithm must ensure the relative position correct; that is to say, if point A is close to point B in GCJ-02 system, this relative spatial relationship persists in WGS-84 system. Therefore, when two points are close, we can approximate to the right coordinates with the iteration algorithm.

See Also

wgs2gcj, conv. the comments of blog http://blog.csdn.net/coolypf/article/details/8686588 in Chinese

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)
# gcj2wgs(39.90245, 116.42703) # correct verifying by google earth
# # convert multiple coordinates
# gcj2wgs(c(39.99967, 39.98691), c(116.3264, 116.3059))
## ---------------------------------------------

Run the code above in your browser using DataLab