forked from ropensci/parzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
139 lines (104 loc) · 3.25 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
parzer
======
```{r echo=FALSE}
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
warning = FALSE,
message = FALSE
)
```
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![Build Status](https://travis-ci.com/ropenscilabs/parzer.svg?branch=master)](https://travis-ci.com/ropenscilabs/parzer)
[![codecov.io](https://codecov.io/github/ropenscilabs/parzer/coverage.svg?branch=master)](https://codecov.io/github/ropenscilabs/parzer?branch=master)
`parzer` parses messy coordinates
You may get data from a published study or a colleague, and the coordinates
may be in some messy format that you'd like to clean up to e.g., have
all decimal degree numeric data.
`parzer` API:
```{r echo=FALSE, comment=NA, results='asis'}
cat(paste(" -", paste(sprintf("`%s`", sort(getNamespaceExports("parzer"))), collapse = "\n - ")))
```
## Installation
```{r eval=FALSE}
remotes::install_github("ropenscilabs/parzer")
```
```{r}
library("parzer")
```
## parse
latitudes
```{r warning=TRUE}
parse_lat("45N54.2356")
parse_lat("-45.98739874")
parse_lat("40.123°")
parse_lat("40.123N")
parse_lat("N45 04.25764")
# bad values -> NaN
parse_lat("191.89")
# many inputs
x <- c("40.123°", "40.123N74.123W", "191.89", 12, "N45 04.25764")
parse_lat(x)
# parse_lat("N455698735", "HDDMMmmmmm") # custom formats not ready yet
```
longitudes
```{r warning=TRUE}
parse_lon("45W54.2356")
parse_lon("-45.98739874")
parse_lon("40.123°")
parse_lon("74.123W")
parse_lon("W45 04.25764")
# bad values
parse_lon("181")
# many inputs
x <- c("45W54.2356", "181", 45, 45.234234, "-45.98739874")
parse_lon(x)
# parse_lon("N455698735", "HDDMMmmmmm") # custom formats not ready yet
```
both lat and lon together
```{r}
lats <- c("40.123°", "40.123N", "191.89", 12, "N45 04.25764")
lons <- c("45W54.2356", "181", 45, 45.234234, "-45.98739874")
parse_lat_lon(lats, lons)
```
parse into degree, min, sec parts
```{r warning=FALSE}
parse_parts_lat("45N54.2356")
parse_parts_lon("-74.6411133")
# many inputs
x <- c("40.123°", "40.123N74.123W", "191.89", 12, "N45 04.25764")
parse_parts_lon(x)
```
get hemisphere from lat/lon coords
```{r}
parse_hemisphere("45N54.2356", "74.123E")
parse_hemisphere("40.4183318", "-120")
parse_hemisphere("-40.4183318", "-120")
parse_hemisphere("-40.4183318", "120")
```
get degree, minutes, or seconds separately
```{r}
coords <- c(45.23323, "40:25:6N", "40° 25´ 5.994\" N")
pz_degree(coords)
pz_minute(coords)
pz_second(coords)
coords <- c(15.23323, "40:25:6E", "192° 25´ 5.994\" E")
pz_degree(lon = coords)
pz_minute(lon = coords)
pz_second(lon = coords)
```
add or subtract degrees, minutes, or seconds
```{r}
d(31)
d(31) + m(44)
d(31) - m(44)
d(31) + m(44) + s(59)
d(-121) + m(1) + s(33)
```
## Meta
* Please [report any issues or bugs](https://github.com/ropenscilabs/parzer/issues).
* License: MIT
* Get citation information for `parzer` in R doing `citation(package = 'parzer')`
* Please note that this project is released with a [Contributor Code of Conduct][coc]
By participating in this project you agree to abide by its terms.
[coc]: https://github.com/ropenscilabs/parzer/blob/master/CODE_OF_CONDUCT.md