Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mayer
CircularGreenSimCity
Commits
4ed3f015
Commit
4ed3f015
authored
Jul 22, 2024
by
Eric Duminil
Browse files
Klimabaeume open data
parent
6fed29db
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
python_scripts/parse_wurzburg_open_data/.gitignore
0 → 100644
View file @
4ed3f015
input/*.parquet
\ No newline at end of file
python_scripts/parse_wurzburg_open_data/Parse parquet.ipynb
0 → 100644
View file @
4ed3f015
This diff is collapsed.
Click to expand it.
python_scripts/parse_wurzburg_open_data/parse_open_data.py
0 → 100644
View file @
4ed3f015
"""
Würzburger Klimabaeume - Bodenfeuchte
https://opendata.wuerzburg.de/explore/dataset/sls-klimabaeume/export/?disjunctive.species_german
"""
from
pathlib
import
Path
import
requests
import
shutil
import
pandas
as
pd
from
rich
import
print
SCRIPT_DIR
=
Path
(
__file__
).
resolve
().
parent
INPUT_DIR
=
SCRIPT_DIR
/
'input'
INPUT_FILE
=
INPUT_DIR
/
'wuerzburg_trees.parquet'
INPUT_URL
=
"https://opendata.wuerzburg.de/api/explore/v2.1/catalog/datasets/sls-klimabaeume/exports/parquet?lang=en&timezone=Europe%2FBerlin"
USER_AGENT
=
{
'User-agent'
:
'Mozilla/5.0'
}
def
download_file
(
download_url
,
download_path
):
with
requests
.
get
(
download_url
,
stream
=
True
,
headers
=
USER_AGENT
)
as
r
:
with
open
(
download_path
,
'wb'
)
as
f
:
shutil
.
copyfileobj
(
r
.
raw
,
f
)
if
INPUT_FILE
.
exists
()
and
INPUT_FILE
.
stat
().
st_size
>
0
:
print
(
f
"
{
INPUT_FILE
}
already here."
)
else
:
print
(
f
"Downloading
{
INPUT_URL
}
"
)
download_file
(
INPUT_URL
,
INPUT_FILE
)
print
(
" Done"
)
df
=
pd
.
read_parquet
(
INPUT_FILE
,
engine
=
'fastparquet'
)
print
(
df
)
interesting_columns
=
[
'tree_number'
,
'species_latin'
,
'latitude'
,
'longitude'
]
species
=
'species_latin'
coordinates
=
[
'latitude'
,
'longitude'
]
df
[
interesting_columns
].
drop_duplicates
().
groupby
(
species
).
apply
(
print
)
df
[
interesting_columns
].
drop_duplicates
().
groupby
(
coordinates
).
apply
(
print
)
python_scripts/parse_wurzburg_open_data/requirements.txt
0 → 100644
View file @
4ed3f015
pandas
requests
fastparquet
folium
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment