Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update habitatmap_stdized and habitatmap_terr #65

Merged
merged 57 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b83de49
update renv files
ToonHub Feb 29, 2024
fbe2d34
add conflict_prefer
ToonHub Feb 29, 2024
646105f
update code to read and process habitatmap 2023 instead of habitatmap…
ToonHub Feb 29, 2024
a281b42
habitatmap_terr: update renv files
ToonHub Feb 29, 2024
c1bb831
habitatmap_terr: add conflict_prefer
ToonHub Feb 29, 2024
af76630
habitatmap_terr: update input data sources version 2020 -> version 2023
ToonHub Feb 29, 2024
8574f1b
generate_habitatmap_stdized: set project to use magrittr pipe *
florisvdh Mar 11, 2024
32146df
generate_habitatmap_stdized: drop unneeded options from setup chunk
florisvdh Mar 11, 2024
efd96b6
generate_habitatmap_stdized: add extra checks on the resulting data s…
florisvdh Mar 11, 2024
a62df40
Merge pull request #67 from inbo/hms_fv
ToonHub Mar 12, 2024
6a41ffb
update time stamp
ToonHub Mar 12, 2024
4a5e9b6
generate_habitatmap_terr: drop unneeded options from setup chunk
ToonHub Mar 12, 2024
073fb5e
generate_habitatmap_terr: add extra checks on the resulting data source
ToonHub Mar 12, 2024
f2e27e6
generate_habitatmap_terr: update md hash habitatmap_stdized
ToonHub Mar 12, 2024
2fbec59
generate_habitatmap_terr: set project to use magrittr pipe *
ToonHub Mar 12, 2024
f4f6d46
wtaersurfaces_hab: update timestamp
ToonHub Mar 26, 2024
e1818fa
wtaersurfaces_hab: update renv
ToonHub Mar 26, 2024
280dd5b
wtaersurfaces_hab: update version of input files
ToonHub Mar 26, 2024
5067a04
wtaersurfaces_hab: update version of input files
ToonHub Mar 26, 2024
04e88ff
Merge branch 'update_habitatmap_stdized_habitatmap_terr' of https://g…
ToonHub Mar 26, 2024
b814ad2
generate_watersurfaces_hab: drop unneeded options from setup chunk
ToonHub Mar 26, 2024
6e9f707
generate watersurfaces_hab: add library
ToonHub Apr 15, 2024
b23bce3
generate watersurfaces_hab: different presentation of invalid geometr…
ToonHub Apr 15, 2024
1256d68
generate watersurfaces_hab: update comparison of different versions
ToonHub Apr 15, 2024
e8285a9
generate habmap_stdized 2023: update renv
cecileherr May 13, 2024
806e124
generate habmap_stdized 2023: update timestamp
cecileherr May 13, 2024
d1c8e8c
generate habmap_stdized 2023: rbbvos+ to rbbvos
cecileherr May 13, 2024
8ba2395
generate habmap_stdized 2023 v1: add leaflet to renv
cecileherr May 14, 2024
b9434e5
generate habmap_stdized 2023 v1: update calculation hashes
cecileherr May 14, 2024
be304bb
generate habmap_stdized 2023 v1: remove user specific filter for vers…
cecileherr May 14, 2024
8d2f196
generate habmap_stdized 2023 v1: textual and minor adaptations
cecileherr May 14, 2024
a20c373
generate habmap_stdized 2023 v1: control geometries and fix invalid p…
cecileherr May 14, 2024
55b1a42
generate habmap_stdized 2023 v1: check validity of geometries in chec…
cecileherr May 14, 2024
b7d88c6
generate habmap_terr 2023 v1: update renv
cecileherr May 14, 2024
2a167a1
generate habmap_terr 2023 v1: check validity of geometries in check_r…
cecileherr May 14, 2024
58014ca
generate habmap_terr 2023 v1: update calculation hashes
cecileherr May 14, 2024
39a06e4
generate habmap_terr 2023 v1: update timestamp
cecileherr May 15, 2024
dbaec60
generate habmap_terr 2023 v1: textual changes
cecileherr May 15, 2024
7205431
generate habmap_terr 2023 v1: remove user specific filter (version)
cecileherr May 15, 2024
71062f9
generate habmap_terr 2023 v1: minor cleaning of code/comments
cecileherr May 15, 2024
b85b7f4
generate habmap_terr 2023 v1: update hashes habmap_stdized
cecileherr May 15, 2024
028e901
generate habmap_terr 2023 v1: remove duplicate PK
cecileherr May 15, 2024
eae2b7c
generate habmap_stdized 2023 v1: minor changes in code/comments
cecileherr May 15, 2024
16b18d1
generate watersurfaces_hab v5: update renv
cecileherr May 15, 2024
ca543fc
generate watersurfaces_hab v5: update time stamp and hashes
cecileherr May 15, 2024
3f6e26c
generate watersurfaces_hab v5: add check for geometry and update calc…
cecileherr May 15, 2024
d8b08c0
generate watersurfaces_hab: textual changes
cecileherr May 21, 2024
089eecb
generate watersurfaces_hab: import layers with corrected geometries
cecileherr May 21, 2024
499b8c5
generate watersurfaces_hab: minor code cleaning
cecileherr May 21, 2024
a2d6370
miscellaneous/habmap: checks for habitatmap
cecileherr May 22, 2024
15f3536
miscellaneous/habitatmap.Rmd: control and fix geometry
cecileherr May 23, 2024
15c0089
generate habmap_terr: solve conflicts after merging with main
cecileherr May 23, 2024
e3d164b
Apply suggestions from code review
ToonHub Sep 3, 2024
d0ed215
generate habmap_terr interp: remove unnecessary call to update zenodo
cecileherr Sep 27, 2024
1074ae3
misc/habitatmap: added reminder about ESRI:102499 vs EPSG:31370
cecileherr Sep 27, 2024
e8fb23b
misc/habitatmap: apply suggestions from code review
cecileherr Sep 27, 2024
abf596e
Merge pull request #70 from inbo/hms_hmt_wsh_2023_ch
cecileherr Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions src/generate_habitatmap_stdized/10_generate_habmap_stdized.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Data source

The shapefile of the BWK and Natura 2000 habitat map of Flanders can be downloaded [here](https://zenodo.org/record/4428002#.YBqzu-hKigY).
The shapefile of the BWK and Natura 2000 habitat map of Flanders can be downloaded [here](https://zenodo.org/record/10167695).

To be sure we will use the correct version of the data source (habitatmap_2020), we will derive the md5 file hashes and compare it to the file hashes in the [data source version overview table](https://docs.google.com/spreadsheets/d/1E8ERlfYwP3OjluL8d7_4rR1W34ka4LRCE35JTxf3WMI/edit#gid=2100595853).
To be sure we will use the correct version of the data source (habitatmap_2023), we will derive the md5 file hashes and compare it to the file hashes in the [data source version overview table](https://docs.google.com/spreadsheets/d/1E8ERlfYwP3OjluL8d7_4rR1W34ka4LRCE35JTxf3WMI/edit#gid=2100595853).

```{r}

Expand All @@ -18,15 +18,18 @@ hashes <-
list.files(path = mypath,
recursive = TRUE)
)) %>%
filter(!str_detect(filepath, "habitatmap_2020|habitatmap_2018")) %>%
#in case you store an older version in a subfolder
mutate(filename = str_match(filepath, "(.+\\/)*(.+)")[,3],
md5 = map(filepath, function(x) {
file(x) %>% md5 %>% str_c(collapse = '')
}) %>% as.character,
md5_ref = c("f767a12540b2bde435c6709c9c9675ad",
"358ff672c2fae48eba5bd09f8a671675",
md5_ref = c("8d436686b2ad4bc9355bf1c403b5ba43",
"358ff672c2fae48eba5bd09f8a671675",
"f881f61a6c07741b58cb618d8bbb0b99",
"1da89a5dc267bbd427c8c07fcf63f344",
"79ae8b4b3c6d970a1f10e78f3eca9ef7"),
"8c6999e914d7f95948d84d5221f58e6f",
"8e9c2c1ef888ce085e027d32f7c73b8c",
"7ff6cc0efbd34f4cfef52d73e466df0d"),
match = md5 == md5_ref) %>%
select(filename,
md5,
Expand Down Expand Up @@ -175,8 +178,18 @@ In this case we will sum the phab-values and create one record for each type.
+ a certain and an uncertain record of the same type, for example:

```{r}

example <- habmap_long %>%
group_by(polygon_id, type) %>%
filter(n() > 1) %>%
filter(any(certain) & any(!certain)) %>%
ungroup()

polygon_id_example <- (example %>%
slice_head(n = 1))$polygon_id

habmap_long %>%
filter(polygon_id == "639375_v2014")
filter(polygon_id == polygon_id_example)
```

We will not aggregate the certain and uncertain record, because we will loose some information used to create `habitatmap_terr`. It is some of the uncertain records (such as `9120, gh`) are eliminated when processing `habitatmap_terr`.
Expand All @@ -202,22 +215,19 @@ habmap_long_aggr <- habmap_long %>%
certain = all(certain)) %>%
ungroup()
```
See below the result of the aggregation for both examples.
See below the result of the aggregation for the first example.

```{r}
habmap_long_aggr %>%
filter(polygon_id == "357179_v2020")
```

```{r}
habmap_long_aggr %>%
filter(polygon_id == "639375_v2014")
```


## Select vegetation types that belong to the standard list of habitat and rbb types

Table \@ref(tab:selectTypes) shows the records with habitat types that do not belong to the standard list of habitat and rbb types. These records are filtered out.
Table \@ref(tab:selectTypes) shows the records with habitat types that do not belong to the standard list of habitat and rbb types.

Good news!
The table is empty

```{r selectTypes}

Expand Down Expand Up @@ -257,6 +267,24 @@ habmap_types_sf <- habmap_sf %>%

```

## Let 's have a quick look at the result

The ID of each polygon in the habitatmap contains the year in which the polygon
was last updated.
In the table below we show the number of records per type and per update year.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


```{r}
habmap_types %>%
mutate(polygon_version = str_sub(polygon_id, start = -4)) %>%
group_by(type, polygon_version) %>%
summarise(n_records = n()) %>%
ungroup() %>%
pivot_wider(names_from = "polygon_version", values_from = "n_records", values_fill = 0) %>%
kable() %>%
kable_styling()
```


## Write results into a geopackage

```{r}
Expand Down
4 changes: 4 additions & 0 deletions src/generate_habitatmap_stdized/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ opts_chunk$set(
echo = TRUE,
dpi = 300
)

conflicted::conflict_prefer("select", "dplyr")
conflicted::conflict_prefer("filter", "dplyr")

# ISO8601 timestamp to set as fixed value in the GeoPackage
# (to be UPDATED to the actual creation date; at least update for each version):
Sys.setenv(OGR_CURRENT_DATE = "2021-03-11T00:00:00.000Z")
Expand Down
Loading