Commit d62f3d0a authored by Batjes, Niels's avatar Batjes, Niels
Browse files

Replace WoSIS_Latest_With_R.Rmd

parent 693d03ae
......@@ -5,6 +5,8 @@ date: "`r format(Sys.Date(), '%d-%B-%Y')`"
output:
word_document:
toc: yes
pdf_document:
toc: yes
html_document:
fig_height: 4
fig_width: 6
......@@ -27,7 +29,7 @@ The "Latest" dynamic dataset contains the most recent version of standardised so
For an overview of WoSIS, see https://www.isric.org/explore/wosis. This links to https://www.isric.org/explore/wosis/accessing-wosis-derived-datasets which explains the difference between snapshot and dynamic datasets, and how to access them.
The [Procedures Manual](http://dx.doi.org/10.17027/isric-wdc-2020-01) describes how the WoSIS database is built.
The [Procedures Manual](https://dx.doi.org/10.17027/isric-wdc-2020-01) describes how the WoSIS database is built.
# Packages
......@@ -71,7 +73,7 @@ We see that ESRI Shapefiles and [OGC GeoPackages](https://www.geopackage.org) ar
# WoSIS Web Feature Service
The "latest" (dynamic) version of WoSIS is provided via
[WFS (Web Feature Services)](http://www.opengeospatial.org/standards/wfs).
[WFS (Web Feature Services)](https://www.opengeospatial.org/standards/wfs).
This is described in less technical terms in [Wikipedia](https://en.wikipedia.org/wiki/Web_Feature_Service).
WFS allows you to incorporate geographic data into your own GIS projects, unlike WMS (Web Map Service), which only displays geographic data within a GIS. Here we use R as the GIS, since it can handle both geographic and feature-space information.
......@@ -81,7 +83,7 @@ WFS allows you to incorporate geographic data into your own GIS projects, unlike
Specify the web address of the "latest" version of WoSIS:
```{r specify.wfs.address}
wfs <- "WFS:http://maps.isric.org/mapserv?map=/map/wosis_latest.map"
wfs <- "WFS:https://maps.isric.org/mapserv?map=/map/wosis_latest.map"
```
List the layers in the WFS source with the `rgdal::ogrinfo` function. This can be somewhat slow, because it depends on the network and the remote server. This function lists information about an OGR-supported data source, including this WFS source. OGR stands for "OGR Simple Features Library", which is now part of GDAL, which stands for "Geospatial Data Abstraction Library", see https://gdal.org for details.
......@@ -144,7 +146,7 @@ ix.g <- grep("GEOGCRS", central.eu.profiles.info)
cat(paste(central.eu.profiles.info[ix.g:(ix.g+17)], collapse="\n"))
```
Here we see the number of profiles in this tile, the extent (a bit smaller than the bounding box we requested), and the CRS formatted as ["Well-Known Text"](http://docs.opengeospatial.org/is/12-063r5/12-063r5.html).
Here we see the number of profiles in this tile, the extent (a bit smaller than the bounding box we requested), and the CRS formatted as ["Well-Known Text"](https://docs.opengeospatial.org/is/12-063r5/12-063r5.html).
The CRS corresponds to [EPSG code](https://www.epsg.org) `4326`, i.e., geographic coördinates on the WGS84 datum.
Show the data field names and their data types. These are listed after the `Geometry Column` line of the metadata:
......@@ -155,7 +157,7 @@ n <- length(central.eu.profiles.info)
central.eu.profiles.info[ix.p+1:n]
```
These are also found in the [Procedures Manual](http://dx.doi.org/10.17027/isric-wdc-2020-01).
These are also found in the [Procedures Manual](https://dx.doi.org/10.17027/isric-wdc-2020-01).
The `rgdal::ogrinfo` function also allows [SQL (Structured Query Language](https://en.wikipedia.org/wiki/SQL) [queries](https://en.wikipedia.org/wiki/SQL_syntax) to limit the extent of the search, by using the optional `where` argument. To use this we need to know the field names, which we saw in the previous output.
......@@ -427,11 +429,8 @@ hist(bd33.india@data$bdfi33_v_1, main="Bulk density, Layers in India",
xlab="g cm-3")
```
Here there are `r dim(bd33.india)[1]` records in `length(unique(bd33.india@data$profile_id))` profiles. These profiles can be found in the profiles database:
Here there are `r dim(bd33.india)[1]` records in `length(unique(bd33.india@data$profile_id))` profiles. These profiles can be found in the profiles database.
```{r}
```
## CSV files {#csv}
......@@ -478,7 +477,7 @@ names(profiles.ceu)
### WoSIS layers as CSV files
Get the the bulk density for the layers in these profiles. Note that this query can not be limited by coordinates, since they are not included in this table. So we get all the layers and then limit to the profiles of interest. This is a very large file, about 97Mb.
Get the the bulk density for the layers in these profiles. Note that this query can not be limited by coordinates, since they are not included in this table. So we get all the layers and then limit to the profiles of interest.
```{r download.bd.csv}
src.layer.name <- "wosis_latest_bdfi33"
......@@ -490,9 +489,11 @@ ogr2ogr(src=wfs,
layer=src.layer.name,
f="CSV",
overwrite=TRUE)
file.info(dst.target.name)$size
file.info(dst.target.name)$size/1024/1024
```
This is a very large file, about 97Mb.
### Read imported layers into R
The bulk density per-layer.
......@@ -531,6 +532,7 @@ system.time(
overwrite=TRUE,
skipfailures=TRUE)
)
file.info(dst.target.name)$size/1024/1024
```
This Geopackage is about 52 Mb.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment