Skip to content

Commit

Permalink
updated the package
Browse files Browse the repository at this point in the history
  • Loading branch information
thiyangt committed Dec 26, 2023
1 parent cca2421 commit 7b140c0
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 618 deletions.
7 changes: 2 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ceylon
Title: Sri Lanka Maps
Version: 0.0.0.9000
Version: 1.0.0
Authors@R:
person(given = "Thiyanga S.",
family = "Talagala",
Expand All @@ -9,11 +9,8 @@ Authors@R:
comment = c(ORCID = "0000-0002-0656-9789"))
Description: Map of Sri Lanka administrative regions, 0-country, 1-province, 2-district and 3-divisional secretariat. R functions for choropleths and other related maps.
Depends: R (>= 3.5.0)
Imports:
sf,
tidyverse
License: CC BY 4.0
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
595 changes: 0 additions & 595 deletions LICENSE.md

This file was deleted.

10 changes: 10 additions & 0 deletions R/rivers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#' Rivers and Streams in Sri Lanka shape file data
#'@description shape file data for rivers and streams
#'\describe{
#'\item{CODE}{River code}
#'\item{NAME}{River name}
#'\item{geometry}{Multipolygon}}
#'@source https://data.humdata.org/dataset/sri-lanka-water-bodies-0-0?#
#'@example
#'data(rivers)
"rivers"
9 changes: 9 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ data(sf_sl_3)
ggplot(sf_sl_3) + geom_sf()
```

### Plotting river network

```{r}
data("rivers")
ggplot(data = sf_sl_0) +
geom_sf(fill="#edf8b1", color="#AAAAAA") +
geom_sf(data=rivers, colour="#253494") +
labs(title = "Sri Lanka Rivers and Streams")
```

### Acknowledgement

Expand Down
55 changes: 37 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ This is a basic example which shows you how to solve a common problem:

``` r
library(ceylon)
#>
#> Attaching package: 'ceylon'
#> The following object is masked from 'package:datasets':
#>
#> rivers
library(tidyverse)
#> ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
#> ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
#> ✓ tibble 3.1.5 ✓ dplyr 1.0.7
#> ✓ tidyr 1.1.4 ✓ stringr 1.4.0
#> ✓ readr 1.4.0 ✓ forcats 0.5.1
#> ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#> ✔ dplyr 1.1.4 ✔ readr 2.1.4
#> ✔ forcats 1.0.0 ✔ stringr 1.5.1
#> ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
#> ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
#> ✔ purrr 1.0.2
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag() masks stats::lag()
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag() masks stats::lag()
#> ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sp)
library(viridis)
#> Loading required package: viridisLite
Expand All @@ -55,17 +62,17 @@ province
#> Bounding box: xmin: 362203.3 ymin: 380301.9 xmax: 621918.1 ymax: 813560.9
#> Projected CRS: SLD99 / Sri Lanka Grid 1999
#> # A tibble: 9 × 4
#> geometry PROVINCE Status population
#> * <MULTIPOLYGON [m]> <chr> <chr> <dbl>
#> 1 (((498211.2 611042.6, 498401.7 610897.1, 498415… CENTRAL Provi… 2781000
#> 2 (((609877 559315.9, 609857.5 559313, 609845.2 5… EASTERN Provi… 1746000
#> 3 (((501928.5 712099.6, 501970.4 712098.8, 502020… NORTH CENT… Provi… 1386000
#> 4 (((393087.5 629959, 393098.1 629956.7, 393103.2… NORTH WEST… Provi… 2563000
#> 5 (((405858.7 700083.7, 405855.3 700082, 405851.5… NORTHERN Provi… 1152000
#> 6 (((432117.3 521875.5, 432083.5 521852.9, 432041… SABARAGAMU… Provi… 2070000
#> 7 (((481925.5 381353.7, 481922.9 381350.3, 481919… SOUTHERN Provi… 2669000
#> 8 (((522825 568220.9, 522872.6 568217.7, 522926.1… UVA Provi… 1387000
#> 9 (((411888.2 438189.4, 411886.4 438182.3, 411881… WESTERN Provi… 6165000
#> geometry PROVINCE Status population
#> * <MULTIPOLYGON [m]> <chr> <chr> <dbl>
#> 1 (((498211.2 611042.6, 498401.7 610897.1, 498415.9 … CENTRAL Provi… 2781000
#> 2 (((609877 559315.9, 609857.5 559313, 609845.2 5593… EASTERN Provi… 1746000
#> 3 (((501928.5 712099.6, 501970.4 712098.8, 502020 71… NORTH C… Provi… 1386000
#> 4 (((393087.5 629959, 393098.1 629956.7, 393103.2 62… NORTH W… Provi… 2563000
#> 5 (((405858.7 700083.7, 405855.3 700082, 405851.5 70… NORTHERN Provi… 1152000
#> 6 (((432117.3 521875.5, 432083.5 521852.9, 432041.7 … SABARAG… Provi… 2070000
#> 7 (((481925.5 381353.7, 481922.9 381350.3, 481919 38… SOUTHERN Provi… 2669000
#> 8 (((522825 568220.9, 522872.6 568217.7, 522926.1 56… UVA Provi… 1387000
#> 9 (((411888.2 438189.4, 411886.4 438182.3, 411881.7 … WESTERN Provi… 6165000
ggplot(province) + geom_sf(mapping = aes(fill = PROVINCE), show.legend = TRUE)
```

Expand Down Expand Up @@ -97,6 +104,18 @@ ggplot(sf_sl_3) + geom_sf()

<img src="man/figures/README-example3-1.png" width="100%" />

### Plotting river network

``` r
data("rivers")
ggplot(data = sf_sl_0) +
geom_sf(fill="#edf8b1", color="#AAAAAA") +
geom_sf(data=rivers, colour="#253494") +
labs(title = "Sri Lanka Rivers and Streams")
```

<img src="man/figures/README-unnamed-chunk-2-1.png" width="100%" />

### Acknowledgement

This package is inspired by the talk given by [Stephanie
Expand Down
22 changes: 22 additions & 0 deletions data-raw/dataraw.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,25 @@ pop_data_district <- pop_table %>%
filter(Status == "District")
pop_sl_1 <- pop_data_district


## river network data (2023-12-26)
#https://blog.benthies.de/blog/mapping-streams-and-rivers-with-ggplot-sf/
# Packages
library(dplyr) # Data manipulation
library(ggplot2) # Plotting
library(sf) # Geometric operations
library(ceylon)
library(sp)

# Sri Lanka Rivers and Streams
#https://data.humdata.org/dataset/sri-lanka-water-bodies-0-0?#
#unzip("lka_rapidsl_rvr_250k_sdlka.zip")
#rivers <- st_read("lka_rapidsl_rvr_250k_sdlka.shp")
#saveRDS(rivers, "rivers.rds")
# Above code is from https://github.com/thiyangt/30DayMapChallenge/blob/main/17_day.R
#take rivers.rds from https://github.com/thiyangt/30DayMapChallenge/blob/main/17_day.R
rivers <- readRDS("~/Lecturer/ceylon/data-raw/rivers.rds")
rivers <- rivers |> st_transform(5235)
rivers <- rivers |>
dplyr::select(CODE, NAME, geometry)
save(rivers, file="data/rivers.rda", compress='xz')
Binary file added data-raw/rivers.rds
Binary file not shown.
Binary file added data/rivers.rda
Binary file not shown.
Binary file modified man/figures/README-example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example0-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/README-unnamed-chunk-2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions man/rivers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7b140c0

Please sign in to comment.