https://github.com/symbolixau/geojsonsf
Conversion between sf and geojson
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.8%) to scientific vocabulary
Keywords
geojson
geospatial
gis
r
rstats
simplefeature
well-known-text
Keywords from Contributors
google-map
geo
mapbox-gl-js
mapbox-gl
deckgl
spatial-analysis
google-maps-javascript-api
google-maps-api
rspatial
proj
Last synced: 5 months ago
·
JSON representation
Repository
Conversion between sf and geojson
Basic Info
- Host: GitHub
- Owner: SymbolixAU
- License: other
- Language: R
- Default Branch: master
- Size: 11.2 MB
Statistics
- Stars: 84
- Watchers: 5
- Forks: 7
- Open Issues: 8
- Releases: 9
Topics
geojson
geospatial
gis
r
rstats
simplefeature
well-known-text
Created almost 8 years ago
· Last pushed over 1 year ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
title: geojsonsf
output: github_document
always_allow_html: yes
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "# ",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[](https://CRAN.R-project.org/package=geojsonsf)

[](https://CRAN.R-project.org/package=geojsonsf)
[](https://github.com/SymbolixAU/geojsonsf)
[](https://github.com/symbolixau/geojsonsf/actions)
[](https://codecov.io/github/SymbolixAU/geojsonsf?branch=master)
--
## geojsonsf
A simple, low-dependency and **fast** converter between GeoJSON and Simple Feature objects in R.
---
**v1.3.2**
Converts
- GeoJSON --> `sf`
- GeoJSON --> `sfc`
- `sf` --> GeoJSON
- `sfc` --> GeoJSON
- GeoJSON --> Well-known text
- data.frame --> GeoJSON (POINT only)
As per GeoJSON ([RFC 7946 specification)](https://tools.ietf.org/html/rfc7946#page-11), foreign members are ignored, and nested objects and arrays inside the `properties` object are converted to string/characters.
Also, as per the specification, **CRS**
> The coordinate reference system for all GeoJSON coordinates is a
geographic coordinate reference system, using the World Geodetic
System 1984 (WGS 84) [WGS84] datum, with longitude and latitude units
of decimal degrees. This is equivalent to the coordinate reference
system identified by the Open Geospatial Consortium (OGC) URN
urn:ogc:def:crs:OGC::CRS84
From **v1.3.2**, if your coordinates are in a different CRS you can specify the CRS & proj4string values in the `geojson_sf()` and `geojson_sfc()` functions.
## Installation
Install the CRAN version with
```{r, eval = F}
install.packages("geojsonsf")
```
To install the development version
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("SymbolixAU/geojsonsf")
```
## Why did you build it?
To quickly parse between GeoJSON and `sf` objects, and to handle cases not supported by `sf`, e.g. arrays of geometries
```{r, echo=FALSE, warning=FALSE, message=FALSE}
library(geojsonsf)
library(sf) ## Loaded for sf print methods
```
## What do you mean, 'cases not supported'
For example, `sf` can't read an array of GeoJSON objects, so I wanted to make this work
```{r}
js <- c(
'[
{"type":"Point","coordinates":[0,0]},
{"type":"LineString","coordinates":[[-1,-1],[1,1]]},
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {"id":1},
"geometry": {"type": "Point", "coordinates": [100.0, 0.0]}
}
]
}
]'
)
sf <- geojson_sf( js )
sf
```
And going the other way you can also return a vector of GeoJSON
```{r}
js <- sf_geojson( sf, atomise = T )
js
```
### What's the benefit of 'atomising'?
It's useful for when you work with geospatial databases and want an individual record for each individual feature.
### What happens if you don't `atomise`?
You get a single GeoJSON object
```{r}
sf_geojson( sf )
```
### Can you remove the properites and just return the geometries
Yes. Call `sfc_geojson()` on the `sfc` object.
```{r}
sfc_geojson( sf$geometry )
```
### If I have an `sf` object without any properties, why does it 'atomise' by default?
```{r}
sf$id <- NULL
sf_geojson( sf )
```
The `simplify` argument is `TRUE` by default, and it will try and 'simplify' the GeoJSON. If there are no properties in the `sf` object, then the GeoJSON won't have any properties.
However, if you set `simplify = FALSE` you'll get a FeatureCollection with an empty properties field.
```{r}
sf_geojson(sf, simplify = F)
```
### How fast is it?
This benchmark shows a comparison with `library(sf)` for converting a string of GeoJSON of 3,221 counties in the US in to an `sf` object
```{r,eval= FALSE}
myurl <- "http://eric.clst.org/assets/wiki/uploads/Stuff/gz_2010_us_050_00_500k.json"
geo <- readLines(myurl)
geo <- paste0(geo, collapse = "")
library(microbenchmark)
microbenchmark(
geojsonsf = {
geojson_sf(geo)
},
sf = {
sf::st_read(geo, quiet = T)
},
times = 2
)
#Unit: milliseconds
# expr min lq mean median uq max neval
# geojsonsf 709.2268 709.2268 722.0626 722.0626 734.8984 734.8984 2
# sf 1867.6840 1867.6840 1958.7968 1958.7968 2049.9097 2049.9097 2
```
Owner
- Name: SymbolixAU
- Login: SymbolixAU
- Kind: organization
- Location: Melbourne, Australia
- Website: symbolix.com.au
- Repositories: 7
- Profile: https://github.com/SymbolixAU
GitHub Events
Total
- Issues event: 2
- Watch event: 3
- Issue comment event: 1
Last Year
- Issues event: 2
- Watch event: 3
- Issue comment event: 1
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| SymbolixAU | d****y@s****u | 288 |
| David | d****1@g****m | 52 |
| SymbolixAU | d****y@S****u | 4 |
| Andy Teucher | a****r@g****m | 3 |
| blacklime | a****s@b****o | 1 |
| dcooley | = | 1 |
| SymbolixAU | d****t@s****u | 1 |
Committer Domains (Top 20 + Academic)
symbolix.com.au: 3
blacklime.io: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 79
- Total pull requests: 23
- Average time to close issues: about 2 months
- Average time to close pull requests: about 1 month
- Total issue authors: 27
- Total pull request authors: 4
- Average comments per issue: 2.32
- Average comments per pull request: 0.3
- Merged pull requests: 21
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: about 3 hours
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 1.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- SymbolixAU (43)
- dcooley (6)
- layik (5)
- lorenzwalthert (2)
- coolbutuseless (1)
- mpadge (1)
- ateucher (1)
- cywhale (1)
- frabau1 (1)
- mem48 (1)
- RobertMyles (1)
- aoles (1)
- SimonGoring (1)
- etiennekintzler (1)
- clozanoruiz (1)
Pull Request Authors
- SymbolixAU (19)
- layik (2)
- ateucher (2)
- techisdead (1)
Top Labels
Issue Labels
bug (4)
enhancement (4)
invalid (1)
wontfix (1)
help wanted (1)
Pull Request Labels
Packages
- Total packages: 4
-
Total downloads:
- cran 135,973 last-month
- Total docker downloads: 951,508
-
Total dependent packages: 40
(may contain duplicates) -
Total dependent repositories: 65
(may contain duplicates) - Total versions: 26
- Total maintainers: 1
proxy.golang.org: github.com/symbolixau/geojsonsf
- Documentation: https://pkg.go.dev/github.com/symbolixau/geojsonsf#section-documentation
- License: other
-
Latest release: v2.0.1+incompatible
published over 5 years ago
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced:
7 months ago
proxy.golang.org: github.com/SymbolixAU/geojsonsf
- Documentation: https://pkg.go.dev/github.com/SymbolixAU/geojsonsf#section-documentation
- License: other
-
Latest release: v2.0.1+incompatible
published over 5 years ago
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced:
6 months ago
cran.r-project.org: geojsonsf
GeoJSON to Simple Feature Converter
- Homepage: https://github.com/SymbolixAU/geojsonsf
- Documentation: http://cran.r-project.org/web/packages/geojsonsf/geojsonsf.pdf
- License: MIT + file LICENSE
-
Latest release: 2.0.3
published over 3 years ago
Rankings
Dependent packages count: 2.1%
Downloads: 2.5%
Dependent repos count: 3.1%
Stargazers count: 4.6%
Average: 6.3%
Forks count: 8.0%
Docker downloads count: 17.6%
Maintainers (1)
Last synced:
6 months ago
conda-forge.org: r-geojsonsf
- Homepage: https://github.com/SymbolixAU/geojsonsf
- License: MIT
-
Latest release: 2.0.3
published over 3 years ago
Rankings
Dependent packages count: 15.6%
Dependent repos count: 20.3%
Average: 29.9%
Stargazers count: 36.1%
Forks count: 47.5%
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.3.0 depends
- Rcpp * imports
- covr * suggests
- jsonify * suggests
- knitr * suggests
- rmarkdown * suggests
- tinytest * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/cache v1 composite
- actions/checkout v2 composite
- actions/upload-artifact master composite
- r-lib/actions/setup-pandoc master composite
- r-lib/actions/setup-r master composite