Skip to contents

This function converts geographical coordinates between different coordinate systems, including WGS-84, GCJ-02 (Chinese National Standard), and BD-09 (Baidu Map).

Usage

convertCoordinates(latitude, longitude, from, to)

Arguments

latitude

Numeric value representing the latitude of the point to convert.

longitude

Numeric value representing the longitude of the point to convert.

from

A character string indicating the source coordinate system. Options include "WGS-84", "GCJ-02", and "BD-09".

to

A character string indicating the target coordinate system. Options include "WGS-84", "GCJ-02", and "BD-09".

Value

A numeric vector of length 2, containing the converted latitude and longitude.

Examples

# Convert WGS-84 coordinates to GCJ-02
convertCoordinates(39.90105, 116.42079, from = "WGS-84", to = "GCJ-02")
#> [1]  39.90245 116.42702

# Convert GCJ-02 coordinates to BD-09
convertCoordinates(39.90245, 116.42702, "GCJ-02", "WGS-84")
#> [1]  39.90105 116.42079

# Convert WGS-84 coordinates to BD-09
convertCoordinates(39.90105, 116.42079, "WGS-84", "BD-09")
#> [1]  39.9085 116.4335