-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathREADME.Rmd
152 lines (115 loc) · 5.24 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
140
141
142
143
144
145
146
147
148
149
150
151
152
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# geojsonio
<!-- badges: start -->
[![R-CMD-check](https://github.com/ropensci/geojsonio/workflows/R-CMD-check/badge.svg)](https://github.com/ropensci/geojsonio/actions?query=workflow%3AR-CMD-check)
[![cran checks](https://badges.cranchecks.info/worst/geojsonio.svg)](https://cran.r-project.org/web/checks/check_results_geojsonio.html)
[![codecov.io](https://codecov.io/github/ropensci/geojsonio/coverage.svg)](https://app.codecov.io/github/ropensci/geojsonio?branch=main)
[![rstudio mirror downloads](https://cranlogs.r-pkg.org/badges/geojsonio)](https://github.com/r-hub/cranlogs.app)
[![cran version](https://www.r-pkg.org/badges/version/geojsonio)](https://cran.r-project.org/package=geojsonio)
[![Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.](https://www.repostatus.org/badges/latest/inactive.svg)](https://www.repostatus.org/#inactive)
<!-- badges: end -->
```{r echo=FALSE}
library("knitr")
hook_output <- knitr::knit_hooks$get("output")
knitr::knit_hooks$set(output = function(x, options) {
lines <- options$output.lines
if (is.null(lines)) {
return(hook_output(x, options)) # pass to default hook
}
x <- unlist(strsplit(x, "\n"))
more <- "..."
if (length(lines)==1) { # first n lines
if (length(x) > lines) {
# truncate the output, but add ....
x <- c(head(x, lines), more)
}
} else {
x <- c(if (abs(lines[1])>1) more else NULL,
x[lines],
if (length(x)>lines[abs(length(lines))]) more else NULL
)
}
# paste these lines together
x <- paste(c(x, ""), collapse = "\n")
hook_output(x, options)
})
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
warning = FALSE,
message = FALSE,
eval = FALSE
)
```
__Convert various data formats to GeoJSON or TopoJSON__
This package is a utility to convert geographic data to GeoJSON and TopoJSON formats. Nothing else. We hope to do this one job very well, and handle all reasonable use cases.
Functions in this package are organized first around what you're working with or want to get, GeoJSON or TopoJSON, then convert to or read from various formats:
* `geojson_list()`/`topojson_list()` - convert to GeoJSON/TopoJSON as R list format
* `geojson_json()`/`topojson_json()` - convert to GeoJSON/TopoJSON as JSON
* `geojson_sp()` - convert output of `geojson_list()` or `geojson_json()` to `sp` spatial objects
* `geojson_sf()` - convert output of `geojson_list()` or `geojson_json()` to `sf` objects
* `geojson_read()`/`topojson_read()` - read a GeoJSON/TopoJSON file from file path or URL
* `geojson_write()`/`topojson_write()` - write a GeoJSON/TopoJSON file locally
Each of the above functions have methods for various objects/classes, including `numeric`, `data.frame`, `list`, `SpatialPolygons`, `SpatialLines`, `SpatialPoints`, etc.
Additional functions:
* `map_gist()` - push up a GeoJSON or topojson file as a GitHub gist (renders as an interactive map)
* `map_leaf()` - create a local interactive map using the `leaflet` package
## \*json Info
* GeoJSON - [spec](https://www.rfc-editor.org/rfc/rfc7946)
* [GeoJSON lint](https://geojsonlint.com/)
* TopoJSON - [spec](https://github.com/topojson/topojson-specification/blob/master/README.md)
## Install
_Mac_
Install `GDAL` on the command line first, e.g., using `homebrew`
```
brew install gdal
```
_Linux_
Get deps first
```{r}
#| echo: true
#| eval: true
remotes::system_requirements("ubuntu", "20.04", package = "geojsonio")
```
__Install geojsonio__
Stable version from CRAN
```{r}
install.packages("geojsonio")
```
Or development version from GitHub
```{r}
install.packages("remotes")
remotes::install_github("ropensci/geojsonio")
```
```{r}
library("geojsonio")
```
## What's the future of geojsonio?
geojsonio is stable and we expect it to stay on CRAN. The package is a
dependency for a number of other packages and is downloaded tens of thousands
of times per month; moving forward the priority with this package is to make
sure that those packages and users are able to keep using the package.
That said, we do not anticipate much further development; there will not likely
be many major new features added or new interfaces developed. We'll avoid
making breaking changes as much as possible.
If you find bugs in geojsonio or want to contribute new features: please feel
free to submit PRs! So long as the existing interface stays intact, we'd be
more than happy to make the package more useful for you. That said, we don't
anticipate being particularly responsive to feature requests
(without a matching PR) moving forward.
## Meta
* Please [report any issues or bugs](https://github.com/ropensci/geojsonio/issues).
* License: MIT
* Get citation information for `geojsonio` in R doing `citation(package = 'geojsonio')`
* Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.