Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Persefone.jl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
638a6bf5
Commit
638a6bf5
authored
2 months ago
by
Marco Matthies
Browse files
Options
Downloads
Patches
Plain Diff
Fix soil type mapping from Bodenatlas identifiers to Persefone soil type enum
parent
1cc51ed4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/world/landscape.jl
+45
-20
45 additions, 20 deletions
src/world/landscape.jl
with
45 additions
and
20 deletions
src/world/landscape.jl
+
45
−
20
View file @
638a6bf5
...
...
@@ -9,27 +9,51 @@ using Printf
"The land cover classes encoded in the Mundialis Sentinel data."
@enum
LandCover
nodata
forest
grass
water
builtup
soil
agriculture
# TODO: check names and order of enum
# TODO: note where values come from
## IMPORTANT: do not change the order of this enum, or initlandscape() will break!
"The soil type"
"The soil type of a Pixel or FarmPlot"
@enum
SoilType
begin
soil
type_no
data
=
0
# 0
soiltype_
sand
# 1
soiltype_
loamy_sand
# 2
soiltype_
sandy_loam
# 3
soiltype_
loam
# 4
soiltype_
silt_loam
# 5
soiltype_
silt
# 6
soiltype_
sandy_clay_loam
# 7
soiltype_
clay_loam
# 8
soiltype_
silty_clay_loam
# 9
soiltype_
sandy_clay
# 10
soiltype_
silty_clay
# 11
soiltype_
clay
# 12
soil
type_unknown
# 13
TODO: invented this to get a type 13
no
soildata
=
0
# 0
sand
# 1
loamy_sand
# 2
sandy_loam
# 3
loam
# 4
silt_loam
# 5
silt
# 6
sandy_clay_loam
# 7
clay_loam
# 8
silty_clay_loam
# 9
sandy_clay
# 10
silty_clay
# 11
clay
# 12
no
soil
# 13
end
# TODO: move this into a CSV file and read it from there
"""Bodenatlas soil type id, corresponding Persefone soil type, and numbers to Persefone SoilType enum and the
original Bodenatlas description of the soil type"""
const
df_soiltypes_bodenatlas
=
DataFrame
(
NamedTuple
{(
:
bodenatlas_id
,
:
bodenatlas_name
,
:
persefone_soiltype
),
Tuple
{
Int
,
String
,
SoilType
}}
.
([
(
1
,
"Abbauflächen"
,
nosoil
),
(
2
,
"Gewässer"
,
nosoil
),
(
3
,
"Lehmsande (ls)"
,
loamy_sand
),
(
4
,
"Lehmschluffe (lu)"
,
silt_loam
),
(
5
,
"Moore"
,
nosoil
),
(
6
,
"Normallehme (ll)"
,
loam
),
(
7
,
"Reinsande (ss)"
,
sand
),
(
8
,
"Sandlehme (sl)"
,
sandy_loam
),
(
9
,
"Schluffsande (us)"
,
sandy_loam
),
(
10
,
"Schlufftone (ut)"
,
silty_clay
),
(
11
,
"Siedlung"
,
nosoil
),
(
12
,
"Tonlehme (tl)"
,
clay_loam
),
(
13
,
"Tonschluffe (tu)"
,
silty_clay_loam
),
(
14
,
"Watt"
,
nosoil
),
])
)
"Map a Bodenatlas soil type integer to a Persefone `SoilType` enum"
const
soiltype_bodenatlas_to_persefone
=
Dict
{
Int
,
SoilType
}(
row
.
bodenatlas_id
=>
row
.
persefone_soiltype
for
row
in
eachrow
(
df_soiltypes_bodenatlas
))
"The types of management event that can be simulated"
@enum
Management
tillage
sowing
fertiliser
pesticide
harvesting
...
...
@@ -53,7 +77,7 @@ end
Pixel
(
landcover
::
LandCover
,
soiltype
::
SoilType
,
fieldid
::
Union
{
Missing
,
Int64
})
=
Pixel
(
landcover
,
soiltype
,
fieldid
,
Vector
{
Management
}(),
Vector
{
Int64
}(),
Vector
{
String
}())
Pixel
(
landcover
::
LandCover
,
fieldid
::
Union
{
Missing
,
Int64
})
=
Pixel
(
landcover
,
soil
type_no
data
,
fieldid
)
Pixel
(
landcover
,
no
soildata
,
fieldid
)
Pixel
(
landcover
::
LandCover
)
=
Pixel
(
landcover
,
missing
)
showlandscape
(
mat
::
T
)
where
T
<:
AbstractMatrix
{
Pixel
}
=
showlandscape
(
stdout
,
mat
)
...
...
@@ -154,8 +178,9 @@ function initlandscape(directory::String, landcovermap::String, farmfieldsmap::S
# convert the numeric landcover value to LandCover, then create the Pixel object
lcv
=
LandCover
(
Int
(
landcover
[
x
,
y
][
1
]
/
10
))
ff
=
Int64
(
farmfields
[
x
,
y
][
1
])
st
=
soiltype_bodenatlas_to_persefone
[
Int
(
soiltypes
[
x
,
y
][
1
])]
(
iszero
(
ff
))
&&
(
ff
=
missing
)
landscape
[
x
,
y
]
=
Pixel
(
lcv
,
ff
)
landscape
[
x
,
y
]
=
Pixel
(
lcv
,
st
,
ff
)
end
end
return
landscape
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment