Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grompy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wit, Allard de
grompy
Commits
4740c6be
Commit
4740c6be
authored
2 months ago
by
Wit, Allard de
Browse files
Options
Downloads
Patches
Plain Diff
Added checks for proper lat/lon.
parent
0c31d639
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
grompy/__init__.py
+1
-1
1 addition, 1 deletion
grompy/__init__.py
grompy/dap.py
+4
-0
4 additions, 0 deletions
grompy/dap.py
grompy/load_data.py
+11
-9
11 additions, 9 deletions
grompy/load_data.py
grompy/util.py
+19
-1
19 additions, 1 deletion
grompy/util.py
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
with
36 additions
and
12 deletions
grompy/__init__.py
+
1
−
1
View file @
4740c6be
...
...
@@ -3,7 +3,7 @@
# Allard de Wit (allard.dewit@wur.nl), October 2021
"""
Grompy is a tool to process and access parcel-based satellite observations from GroenMonitor.nl.
"""
__version__
=
"
1.6.
1
"
__version__
=
"
1.6.
2
"
from
.dap
import
DataAccessProvider
from
.cmd
import
cli
...
...
This diff is collapsed.
Click to expand it.
grompy/dap.py
+
4
−
0
View file @
4740c6be
...
...
@@ -233,7 +233,11 @@ class DataAccessProvider:
d
[
dataset_name
]
=
df
c
=
SimpleNamespace
(
**
d
)
assert
(
50
<
parcel_info
.
latitude
<
54
),
f
"
Latitude out of range
{
parcel_info
.
latitude
}
, did you invert x and y?
"
assert
(
3.0
<
parcel_info
.
longitude
<
7.5
),
f
"
Longitude out of range
{
parcel_info
.
longitude
}
, did you invert x and y?
"
yield
parcel_info
,
c
rows
=
r
.
fetchmany
(
100
)
def
__len__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
grompy/load_data.py
+
11
−
9
View file @
4740c6be
...
...
@@ -13,7 +13,7 @@ import numpy as np
import
yaml
import
duckdb
from
.util
import
prepare_db
,
make_path_absolute
,
get_latlon_from_RD
from
.util
import
prepare_db
,
make_path_absolute
,
get_latlon_from_RD
,
check_naam
,
check_PC4
class
CSVLoadingError
(
Exception
):
...
...
@@ -53,7 +53,9 @@ def load_parcel_info(grompy_yaml, gpkg_fname, counts_file_10m, counts_file_20m,
r
=
[]
for
row
in
df
.
itertuples
():
x
,
y
=
float
(
row
.
geometry
.
centroid
.
x
),
float
(
row
.
geometry
.
centroid
.
y
)
lon
,
lat
=
get_latlon_from_RD
(
x
,
y
)
lat
,
lon
=
get_latlon_from_RD
(
x
,
y
)
assert
(
50
<
lat
<
54
),
f
"
Latitude out of range
{
lat
}
, did you invert x and y?
"
assert
(
3.0
<
lon
<
7.5
),
f
"
Longitude out of range
{
lon
}
, did you invert x and y?
"
r
.
append
({
"
fieldid
"
:
row
.
Index
,
"
latitude
"
:
lat
,
"
longitude
"
:
lon
,
"
rdx
"
:
x
,
"
rdy
"
:
y
})
df_latlon
=
pd
.
DataFrame
(
r
).
set_index
(
"
fieldid
"
)
df
=
df
.
join
(
df_latlon
)
...
...
@@ -82,15 +84,15 @@ def load_parcel_info(grompy_yaml, gpkg_fname, counts_file_10m, counts_file_20m,
"
rdy
"
:
df
.
rdy
,
"
longitude
"
:
df
.
longitude
,
"
latitude
"
:
df
.
latitude
,
"
cat_gewasc
"
:
df
.
cat_gewasc
.
apply
(
str
),
"
cat_gewasc
"
:
df
.
cat_gewasc
.
apply
(
check_naam
),
"
gws_gewasc
"
:
df
.
gws_gewasc
.
astype
(
np
.
int32
),
"
provincie
"
:
df
.
provincie
.
apply
(
str
),
"
gemeente
"
:
df
.
gemeente
.
apply
(
str
),
"
regio
"
:
df
.
regio
.
apply
(
str
),
"
pc4
"
:
df
.
PC4
.
apply
(
lambda
pc4
:
str
(
int
(
pc4
))
),
"
provincie
"
:
df
.
provincie
.
apply
(
check_naam
),
"
gemeente
"
:
df
.
gemeente
.
apply
(
check_naam
),
"
regio
"
:
df
.
regio
.
apply
(
check_naam
),
"
pc4
"
:
df
.
PC4
.
apply
(
check_PC4
),
"
AHN2
"
:
df
.
AHN2
,
"
woonplaats
"
:
df
.
woonplaats
.
apply
(
str
),
"
waterschap
"
:
df
.
waterschap
.
apply
(
str
),
"
woonplaats
"
:
df
.
woonplaats
.
apply
(
check_naam
),
"
waterschap
"
:
df
.
waterschap
.
apply
(
check_naam
),
"
S2_Tiles
"
:
df
.
S2_Tiles
.
apply
(
str
),
"
geometry
"
:
df
.
geometry
},
crs
=
df
.
crs
)
...
...
This diff is collapsed.
Click to expand it.
grompy/util.py
+
19
−
1
View file @
4740c6be
...
...
@@ -105,6 +105,8 @@ def open_DB_connection(grompy_yaml, dsn):
def
get_latlon_from_RD
(
x
,
y
,
_cache
=
{}):
"""
Converts given X,Y in the Dutch RD coordinate system towards latitude longitude in WGS84
returns: (latitude, longitude)
For checking:
in RD coordinate system X, Y: 197903, 309096
should be in WGS84 latitude, longitude: 50.770195900951045, 5.995343676754713
...
...
@@ -128,4 +130,20 @@ def check_grompy_version(grompy_yaml):
msg
=
f
"
grompy.yaml (
{
v1
}
) does not match grompy version (
{
v2
}
)!
"
\
"
Generate a new grompy.yaml file with `grompy init`
"
\
"
and adapt it.
"
raise
RuntimeError
(
msg
)
\ No newline at end of file
raise
RuntimeError
(
msg
)
def
check_PC4
(
postal_code
):
try
:
pc4
=
str
(
int
(
postal_code
))
except
ValueError
as
e
:
pc4
=
"
0000
"
return
pc4
def
check_naam
(
name
):
try
:
n
=
str
(
name
)
except
ValueError
as
e
:
n
=
"
Unknown
"
return
n
This diff is collapsed.
Click to expand it.
pyproject.toml
+
1
−
1
View file @
4740c6be
...
...
@@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"
[project]
name
=
"grompy"
version
=
"1.6.
1
"
version
=
"1.6.
2
"
description
=
"GROMPY is a tool for storing and accessing Groenmonitor satellite time-series for agricultural parcels."
authors
=
[
{name
=
"Allard de Wit"
,
email
=
"allard.dewit@wur.nl"
}
,
...
...
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