Description Usage Arguments Details Value Author(s) See Also Examples
Analyzes the coordinates (lat, lon) to check whether they are in or out of China. You can choose to return a logical vector or a ggplot2 object for quick visualization.
1 2 3 4 |
y |
one of
|
... |
one of
|
accurate |
logical, whether use accurate China boundary to analyze
the coordinates. Default TRUE. When using the accurate China boundary,
the function will check if the coordinates (Lat, Lon) are actually inside
China's territory. When set FALSE, the function will use a very vague rectangle
defined by |
gcs |
character, the geo-coordinate system, 'WGS-84', 'GCJ-02' or 'BD-09'. Default 'WGS-84'. The function will analyze the points (Lat, Lon) under the specific gcs. |
plot |
logical, if generate a plot to show the location of the points. |
canvas |
character, 'china' or 'world'. It is only effective when
|
xlim |
numeric vector of length 2. The longitude limits of the China map.
Default c(72.004, 137.8347). when |
ylim |
numeric vector of length 2. The latitude limits of the China map.
Default c(0.8293, 55.8271). when |
auto_fix_latlng |
logical, if the lat/lng data is of the opposite order, whether to let the function automatically fix it. Default TRUE. |
The most popular open-source coordinate transformation algorithm regards China as a rectangle. Points outside this rectangle are treated as 'outside China', of which case the conversion from WGS-84 ==> GCJ-02 / BD-09 is not conducted. This function inherits this algorithm as well. As a step further, it prepares an 'accurate' method that use the actual China boundary to analyze the input points. Due to the limitation of proj.4 library, it plots the points and China boundary under 'WGS-84' system.
Depends on plot
,
TRUE
: returns a 'ggplot2' object.
FALSE
; returns a logical vector with the same length of Lat (or Lon).
. Note that the point pairs with either lat or lng missing will yield NA anyway.
Yiying Wang, wangy@aetna.com
Refer to transform_coord
function family for argument y, ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## Not run:
is_out_of_china(c(10, 30, 40, 50, 70), c(100, 120, 100, 140, 160),
accurate_=TRUE)
# 10.00,100.00 30.00,120.00 40.00,100.00 50.00,140.00 70.00,160.00
# TRUE FALSE FALSE TRUE TRUE
is_out_of_china(c(10, 30, 40, 50, 70), c(100, 120, 100, 140, 160),
accurate=FALSE)
# 10.00,100.00 30.00,120.00 40.00,100.00 50.00,140.00 70.00,160.00
# FALSE FALSE FALSE TRUE TRUE
## visualize the positions
is_out_of_china(c(10, 30, 40, 50, 70), c(100, 120, 100, 140, 160),
plot=TRUE, canvas='china')
is_out_of_china(c(10, 30, 40, 50, 70), c(100, 120, 100, 140, 160),
plot=TRUE, canvas='world')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.