The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
To install and discover the package, please read the lczexplore_english vignette. To load it simply type:
Usecase: comparing the LCZ available on the WUDAPT european LCZ map and the Geoclimate approach using OpenStreetMap input data
This vignette illustrates the use of the package to compare maps produced with different approaches, it does not aim at drawing conclusion on the relevance of these methods, nor does it aim at describing them in details.
The World Urban Database and Access Portal Tools is a project which aims at creating LCZ with earth observation data. The details of the project and the related papers can be found on the website of the project: https://www.wudapt.org/
The map we are going to use in this vignette is the European LCZ map, as described in the paper available at the following url: https://doi.org/10.1371/journal.pone.0214474
As this method is one of the most used we included the map tif in the embedded data of the package.
The first step is to define a bounding box of the territory of
interest. The lczexplore comes with vector data for the Redon Territory,
a rural town of Brittany, France. The importLCZvect is a generic import
function for vector data, and when the ouput argument is
set to bBox, it returns the bounding box of the input
layer. Any bounding box of the bounding box class of the package
sf can be used to crop the raster map. We can use a
bounding box created from a vector file. Or create a bounding box from
its coordinates. The package osmdata also offers the getbb() function
which allow to get the bounding box from a location if it is named in
openStreetMap.
redonBbox<-importLCZvect(dirPath=paste0(system.file("extdata", package = "lczexplore"),
"/multipleWfs/Redon"), file="osm_lcz.fgb",column="LCZ_PRIMARY",output="bBox")
# Example with osmdata function getbb, not run, to avoid installation of the package
# library(osmdata)
# redonBbox<-getbb("Redon", format_out = "sf_polygon")The second step is to import the raster map and use the previous bounding box to crop the territory of interest. The importLCZraster function performs this in a simple call:
redonWudapt<-importLCZraster(system.file("extdata", package = "lczexplore"),
fileName="redonWudapt.tif", bBox=redonBbox)
#> Warning: attribute variables are assumed to be spatially constant throughout
#> all geometriesThe resulting object is an sf file, the pixels of the geotiff have been transformed into geometries. The input file must be a geotiff, whose CRS will be read by the function.
library(sf)
#> Linking to GEOS 3.14.1, GDAL 3.12.2, PROJ 9.7.1; sf_use_s2() is TRUE
st_crs(redonWudapt)
#> Coordinate Reference System:
#> User input: ETRS89-extended / LAEA Europe
#> wkt:
#> PROJCRS["ETRS89-extended / LAEA Europe",
#> BASEGEOGCRS["ETRS89",
#> ENSEMBLE["European Terrestrial Reference System 1989 ensemble",
#> MEMBER["European Terrestrial Reference Frame 1989"],
#> MEMBER["European Terrestrial Reference Frame 1990"],
#> MEMBER["European Terrestrial Reference Frame 1991"],
#> MEMBER["European Terrestrial Reference Frame 1992"],
#> MEMBER["European Terrestrial Reference Frame 1993"],
#> MEMBER["European Terrestrial Reference Frame 1994"],
#> MEMBER["European Terrestrial Reference Frame 1996"],
#> MEMBER["European Terrestrial Reference Frame 1997"],
#> MEMBER["European Terrestrial Reference Frame 2000"],
#> MEMBER["European Terrestrial Reference Frame 2005"],
#> MEMBER["European Terrestrial Reference Frame 2014"],
#> MEMBER["European Terrestrial Reference Frame 2020"],
#> ELLIPSOID["GRS 1980",6378137,298.257222101,
#> LENGTHUNIT["metre",1]],
#> ENSEMBLEACCURACY[0.1]],
#> PRIMEM["Greenwich",0,
#> ANGLEUNIT["degree",0.0174532925199433]],
#> ID["EPSG",4258]],
#> CONVERSION["Europe Equal Area 2001",
#> METHOD["Lambert Azimuthal Equal Area",
#> ID["EPSG",9820]],
#> PARAMETER["Latitude of natural origin",52,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8801]],
#> PARAMETER["Longitude of natural origin",10,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8802]],
#> PARAMETER["False easting",4321000,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8806]],
#> PARAMETER["False northing",3210000,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8807]]],
#> CS[Cartesian,2],
#> AXIS["northing (Y)",north,
#> ORDER[1],
#> LENGTHUNIT["metre",1]],
#> AXIS["easting (X)",east,
#> ORDER[2],
#> LENGTHUNIT["metre",1]],
#> USAGE[
#> SCOPE["Statistical analysis."],
#> AREA["Europe - European Union (EU) countries and candidates. Europe - onshore and offshore: Albania; Andorra; Austria; Belgium; Bosnia and Herzegovina; Bulgaria; Croatia; Cyprus; Czechia; Denmark; Estonia; Faroe Islands; Finland; France; Germany; Gibraltar; Greece; Hungary; Iceland; Ireland; Italy; Kosovo; Latvia; Liechtenstein; Lithuania; Luxembourg; Malta; Monaco; Montenegro; Netherlands; North Macedonia; Norway including Svalbard and Jan Mayen; Poland; Portugal including Madeira and Azores; Romania; San Marino; Serbia; Slovakia; Slovenia; Spain including Canary Islands; Sweden; Switzerland; Türkiye (Turkey); United Kingdom (UK) including Channel Islands and Isle of Man; Vatican City State."],
#> BBOX[24.6,-35.58,84.73,44.83]],
#> ID["EPSG",3035]]The LCZ are expressed with several conventions. We chose to use 1 to 10 for the urban and 101 to 107 for the land-use types.
One can then use standard R functions to explore the data.
summary(redonWudapt)
#> EU_LCZ_map geometry geomID
#> 6 :104 POLYGON :208 Length:208
#> 104 : 56 epsg:3035 : 0 Class :character
#> 102 : 35 +proj=laea...: 0 Mode :character
#> 3 : 11
#> 8 : 1
#> 101 : 1
#> (Other): 0
summary(redonWudapt$EU_LCZ_map)
#> 1 2 3 4 5 6 7 8 9 10 101 102 103 104 105 106 107
#> 0 0 11 0 0 104 0 1 0 0 1 35 0 56 0 0 0One can see, for instance that no pixel of the imported territory set to one of the following levels: 1, 2, 4, 5, 7, 10, 103 or 105, or that the most present LCZ type is 104, with 1116 pixels.
Once the dataset has been loaded into an R object of class
sf, the function showLCZ produces the map of
it’s repartition. The argumentsf sets the input dataset,
the column of the LCZ types is passed to the argument
column. The argument wf is just a string that
will be used to produce the title of the plot, and it allows the user to
specify which workflow produced the input data.
For standard LCZ types, one sets the argument
repr="standard", and the function will recognize levels
from 1 to 10 and from 101 to 107. It is the recommended choice. But
standard representation will also accept levels from 11 to
17 and from A to G.
The following code shows an example of color choice.
These data are embedded in lczexplore. On can import
them using the importLCZvect function. This function allows
to load geojson or shp files, and one must specify the name of the
column containing the LCZ types.
# Path to OSM data specifically
dirPathOSM<-system.file("extdata/multipleWfs/Redon",package="lczexplore")
# loading Redon Data produced with GeoClimate on OSM input Data
redonOSM<-importLCZvect(dirPath=dirPathOSM,file="osm_lcz.fgb",column = "LCZ_PRIMARY", drop=TRUE)
summary(redonOSM$LCZ_PRIMARY)
#> 101 102 103 104 105 106
#> 7 1 0 22 23 0
#> 107 1 2 3 4 5
#> 9 0 13 0 0 1
#> 6 7 8 9 10 Unclassified
#> 14 0 4 11 0 0The purpose of this package is to easily compare local climate zone classifications produced by different algorithms on the same study area.
The compareLCZ function intersects the geometries of
both input sf files. The resulting geometries then either agree or
disagree. Both maps are plotted and a map of where they agree is
produced. A confusion matrix is also plotted, revealing how each LCZ
type of the first dataset break up into the LCZ types of the second
dataset. If the two datasets are not in the same coordinate reference
system (CRS), the function will ask which CRS will be kept.
summary(redonOSM)
#> ID_RSU LCZ_PRIMARY LCZ_UNIQUENESS_VALUE geometry
#> Min. : 27.0 105 :23 Min. :0.01899 MULTIPOLYGON :105
#> 1st Qu.:153.0 104 :22 1st Qu.:0.26532 epsg:32630 : 0
#> Median :230.0 6 :14 Median :0.62994 +proj=utm ...: 0
#> Mean :216.2 2 :13 Mean :0.60639
#> 3rd Qu.:284.0 9 :11 3rd Qu.:0.92071
#> Max. :320.0 107 : 9 Max. :1.00000
#> (Other):13 NA's :66
summary(redonWudapt)
#> EU_LCZ_map geometry geomID
#> 6 :104 POLYGON :208 Length:208
#> 104 : 56 epsg:3035 : 0 Class :character
#> 102 : 35 +proj=laea...: 0 Mode :character
#> 3 : 11
#> 8 : 1
#> 101 : 1
#> (Other): 0
compareLCZ(sf1 = redonWudapt, column1 = "EU_LCZ_map", wf1="WUDAPT",
sf2 = redonOSM, column2 = "LCZ_PRIMARY", wf2 = "GeoClimate_OSM",
ref=1 ,exwrite=FALSE,saveG = "comparisonR" )
#> The column EU_LCZ_map of the dataset sf1 is the reference against which the LCZ_PRIMARY column of the dataset sf2 will be compared.
#> For Technical reason in this package, worfklow names can't contain spaces or underscores, they were replaced by dots
#> Workflow names are used in produced graphics and as column names, long names are not suitable,
#> the first 3 and last 3 letters were kept instead
#> Both sf datasets need to live in the same crs projection (srid / epsg),
#> they will be coerced to the specified reference (sf1)
#> Warning: attribute variables are assumed to be spatially constant throughout
#> all geometriesThe intent of this section is not to discuss the quality of the algorithms used for example, but to illustrate how the package allow to compare grouped categories.
For instance, 51% of the areas of Redon that Wudapt classifies as compact low are seen as compact mid by Geoclimate on OpenStreet map input data. And 34% of what Wudapt classifies as open low are seen as sparsely built by GeoClimate.
But how do Wudapt and GeoClimate agree on broader categories, as
built LCZ versus vegetation LCZ ? One could group these LCZs to explore
this, using the groupLCZ function.
# Regroup levels of the WUDAPT sf file.
redonWudaptGrouped<-groupLCZ(redonWudapt,column="EU_LCZ_map",
urban=c("1","2","3","4","5","6","7","8","9"),
industry="10", vegetation=c("101","102","103","104"),
impervious="105",pervious="106",water="107", outCol = "Regrouped")
#> Grouping
#> One of the specified levels to group doesn't exist in the data, if it is a mispelled level of the data,
#> this level will be kept as ungroupedsimpleWarning: Unknown levels in `f`: 1, 2, 4, 5, 7, 9, 10, 103, 105, 106, 107
#> Warning: Unknown levels in `f`: 1, 2, 4, 5, 7, 9, 10, 103, 105, 106, 107
# Regroup levels of the GeoClimate sf file
redonOSMgrouped<-groupLCZ(redonOSM, column="LCZ_PRIMARY",
urban=c("1","2","3","4","5","6","7","8","9"),
industry="10", vegetation=c("101","102","103","104"),
impervious="105",pervious="106",water="107", outCol = "Regrouped")
#> Grouping
#> One of the specified levels to group doesn't exist in the data, if it is a mispelled level of the data,
#> this level will be kept as ungroupedsimpleWarning: Unknown levels in `f`: 1, 3, 4, 7, 10, 103, 106
#> Warning: Unknown levels in `f`: 1, 3, 4, 7, 10, 103, 106
# Pass the files, the columsn and a vector of colors associated to the broader categories
compareLCZ(sf1 = redonWudaptGrouped, column1 = "Regrouped", wf1 = "Wudapt",
sf2 = redonOSMgrouped, column2 = "Regrouped", wf2 = " GeoClimate on OSM data",
exwrite = FALSE, plot=TRUE, repr="alter", levels=c("urban","industry","vegetation","impervious","pervious","water"),colors=c("red","black","green","grey","burlywood","blue"), saveG="comparisonGroupedR")
#> The column Regrouped of the dataset sf1 is the reference against which the Regrouped column of the dataset sf2 will be compared.
#> For Technical reason in this package, worfklow names can't contain spaces or underscores, they were replaced by dots
#> Workflow names are used in produced graphics and as column names, long names are not suitable,
#> the first 3 and last 3 letters were kept instead
#> Both sf datasets need to live in the same crs projection (srid / epsg),
#> they will be coerced to the specified reference (sf1)
#> Warning: attribute variables are assumed to be spatially constant throughout
#> all geometries
#> typeLevels before trying to group are redtypeLevels before trying to group are blacktypeLevels before trying to group are greentypeLevels before trying to group are greytypeLevels before trying to group are burlywoodtypeLevels before trying to group are bluetypeLevels before trying to group are #57f95f
#> One vector of levels, one vector of colors, either the same length (case 9: and 10:), or colors longer (case 12:, unused colors were dropped),
#> reduced to 6: A single vector was provided, whose names don't cover the levels in the data,
#> missing levels were assigned random colors.
#> As useStandCol is set to TRUE, some of the specified colors may have been over-ridden to use standard colors if standard LCZ values have been detected
#> standard LCZ types detected, the standard colors will be associated to them: redstandard LCZ types detected, the standard colors will be associated to them: blackstandard LCZ types detected, the standard colors will be associated to them: greenstandard LCZ types detected, the standard colors will be associated to them: greystandard LCZ types detected, the standard colors will be associated to them: burlywoodstandard LCZ types detected, the standard colors will be associated to them: bluestandard LCZ types detected, the standard colors will be associated to them: ghostwhite
#> typeLevels before trying to group are redtypeLevels before trying to group are blacktypeLevels before trying to group are greentypeLevels before trying to group are greytypeLevels before trying to group are burlywoodtypeLevels before trying to group are bluetypeLevels before trying to group are #5a06c9
#> One vector of levels, one vector of colors, either the same length (case 9: and 10:), or colors longer (case 12:, unused colors were dropped),
#> reduced to 6: A single vector was provided, whose names don't cover the levels in the data,
#> missing levels were assigned random colors.
#> As useStandCol is set to TRUE, some of the specified colors may have been over-ridden to use standard colors if standard LCZ values have been detected
#> standard LCZ types detected, the standard colors will be associated to them: redstandard LCZ types detected, the standard colors will be associated to them: blackstandard LCZ types detected, the standard colors will be associated to them: greenstandard LCZ types detected, the standard colors will be associated to them: greystandard LCZ types detected, the standard colors will be associated to them: burlywoodstandard LCZ types detected, the standard colors will be associated to them: bluestandard LCZ types detected, the standard colors will be associated to them: ghostwhite
One can notice that the two explored algorithms agree rather well about vegetation, as 87% of the surface WUDAPT classifies as vegetation is classified as vegetation by Geoclimate. On urban LCZ, while 68% of the surface WUDAPT classifies as urban is also classified as urban by GeoClimate, 19% is classified as vegetation and 12% as impervious by GeoClimate.
The confusion matrix compare percentage of areas, so if the global area concerned is small, one has to be careful about the interpretation. For instance, the very strong agreement about pervious soils or the relative agreement about water should not be over interpreted as they only represent less than 1% of the areas of the WUDAPT generated map.
For more details on the package, browse other vignettes.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.