Skip to content

Commit

Permalink
geojson example in README [no ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbutuseless committed Mar 18, 2024
1 parent 5688a9d commit aeb3276
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
13 changes: 12 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ remotes::install_github('coolbutuseless/yyjsonr')



Simple usage example
Simple JSON example
==============================================================================

```{r}
Expand All @@ -129,6 +129,17 @@ read_json_str(str)
```


Simple GeoJSON example
==============================================================================

When parsing GeoJSON, `{yyjsonr}` returns an `sf` object.

```{r}
read_geojson_str(geojsonsf::geo_melbourne) |>
head() |>
sf:::print.sf()
```


## Limitations

Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ with:
remotes::install_github('coolbutuseless/yyjsonr')
```

# Simple usage example
# Simple JSON example

``` r
library(yyjsonr)
Expand Down Expand Up @@ -117,6 +117,35 @@ read_json_str(str)
#> 3 4.7 3.2 1.3 0.2 setosa
```

# Simple GeoJSON example

When parsing GeoJSON, `{yyjsonr}` returns an `sf` object.

``` r
read_geojson_str(geojsonsf::geo_melbourne) |>
head() |>
sf:::print.sf()
#> Simple feature collection with 6 features and 7 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 144.8958 ymin: -37.86631 xmax: 145.0371 ymax: -37.75423
#> Geodetic CRS: WGS 84
#> SA2_NAME polygonId SA3_NAME AREASQKM fillColor
#> 1 Abbotsford 70 Yarra 1.7405 #440154
#> 2 Albert Park 59 Port Phillip 4.6747 #450457
#> 3 Alphington - Fairfield 41 Darebin - South 2.8853 #46075A
#> 4 Armadale 66 Stonnington - West 2.1835 #460A5D
#> 5 Ascot Vale 44 Essendon 3.8361 #460C5F
#> 6 Brunswick 36 Brunswick - Coburg 5.1425 #472D7B
#> strokeColor strokeWeight geometry
#> 1 #440154 1 POLYGON ((144.9925 -37.8024...
#> 2 #450457 1 POLYGON ((144.9449 -37.8437...
#> 3 #46075A 1 POLYGON ((145.0204 -37.7654...
#> 4 #460A5D 1 POLYGON ((145.0117 -37.8535...
#> 5 #460C5F 1 POLYGON ((144.8994 -37.7704...
#> 6 #472D7B 1 POLYGON ((144.9497 -37.7627...
```

## Limitations

- Some datatypes not currently supported. Please file an issue on GitHub
Expand Down

0 comments on commit aeb3276

Please sign in to comment.