Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
Germany Open-Data CityGML
Commits
ea94b15c
Commit
ea94b15c
authored
Nov 14, 2025
by
Eric Duminil
Browse files
Proof of concept for Sachsen
parent
8fadce6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
13_sachsen.py
View file @
ea94b15c
...
@@ -4,18 +4,51 @@
...
@@ -4,18 +4,51 @@
# https://geodienste.sachsen.de/ags-relay/ArcGISServer/guest/arcgis/rest/services/geosn/rest_geosn_downloadlinks/MapServer/3
# https://geodienste.sachsen.de/ags-relay/ArcGISServer/guest/arcgis/rest/services/geosn/rest_geosn_downloadlinks/MapServer/3
import
pandas
as
pd
import
json
from
datetime
import
datetime
import
requests
import
requests
MAP_SERVICE_URL
=
"https://geodienste.sachsen.de/ags-relay/ArcGISServer/guest/arcgis/rest/services/geosn/rest_geosn_downloadlinks/MapServer/3/query"
from
citygml_download
import
TMP_DIR
,
Bundesland
,
CityGMLWithDate
,
download_all_files
,
download_file
SACHSEN
=
Bundesland
(
"Sachsen"
,
source
=
"https://geodienste.sachsen.de/ags-relay/ArcGISServer/guest/arcgis/rest/services/geosn/rest_geosn_downloadlinks/MapServer/3/query"
,
info
=
"https://www.geodaten.sachsen.de/"
,
)
PAGE_SIZE
=
1000
# Max amount for Sachsen Server
PAGE_SIZE
=
1000
# Max amount for Sachsen Server
all_tiles
=
[]
all_tiles
=
[]
current_offset
=
0
current_offset
=
0
print
(
f
"Starting paged query to retrieve all tiles (page size:
{
PAGE_SIZE
}
)..."
)
print
(
f
"Starting paged query to retrieve all tiles (page size:
{
PAGE_SIZE
}
)..."
)
def
get_lod2_key
(
url
:
str
)
->
str
:
batch_html_path
=
TMP_DIR
/
"sachsen_batch.html"
try
:
download_file
(
url
,
batch_html_path
)
with
open
(
batch_html_path
)
as
batch_html
:
lines
=
batch_html
.
readlines
()
interesting
=
next
(
line
for
line
in
lines
if
"products="
in
line
)
products
=
json
.
loads
(
interesting
.
split
(
"="
)[
1
])
lod2
=
products
[
"LoD2_CityGML"
]
return
lod2
[
"share_id"
]
except
Exception
as
e
:
print
(
f
"❌ Something went wrong while trying to get key to download GMLs
{
e
}
"
)
# Hoping it's still the correct one:
return
"AyJqXpJAZJXomCb"
keep_downloading
=
True
keep_downloading
=
True
citygmls
=
[]
KEY
=
get_lod2_key
(
"https://www.geodaten.sachsen.de/batch-download-4719.html"
)
DOWNLOAD_SERVER
=
f
"https://geocloud.landesvermessung.sachsen.de/public.php/dav/files/
{
KEY
}
/"
while
keep_downloading
:
while
keep_downloading
:
QUERY_PARAMS
=
{
QUERY_PARAMS
=
{
...
@@ -28,7 +61,7 @@ while keep_downloading:
...
@@ -28,7 +61,7 @@ while keep_downloading:
}
}
try
:
try
:
response
=
requests
.
get
(
MAP_SERVICE_URL
,
params
=
QUERY_PARAMS
)
response
=
requests
.
get
(
SACHSEN
.
source
,
params
=
QUERY_PARAMS
)
response
.
raise_for_status
()
response
.
raise_for_status
()
data
=
response
.
json
()
data
=
response
.
json
()
keep_downloading
=
data
.
get
(
"exceededTransferLimit"
,
False
)
keep_downloading
=
data
.
get
(
"exceededTransferLimit"
,
False
)
...
@@ -38,13 +71,29 @@ while keep_downloading:
...
@@ -38,13 +71,29 @@ while keep_downloading:
break
break
if
"features"
in
data
and
data
[
"features"
]:
if
"features"
in
data
and
data
[
"features"
]:
features
=
data
[
"features"
]
import
rich
tile_list
=
[
f
[
"attributes"
]
for
f
in
features
]
print
()
all_tiles
.
extend
(
tile_list
)
for
feature
in
data
[
"features"
]:
attributes
=
feature
[
"attributes"
]
print
(
f
" -> Retrieved
{
len
(
tile_list
)
}
tiles. Total gathered:
{
len
(
all_tiles
)
}
"
)
import
rich
rich
.
print
(
feature
)
filename
=
attributes
[
"Download_CityGML"
].
split
(
"/"
)[
-
1
]
year
=
int
(
attributes
[
"Stand"
].
split
(
"("
)[
0
])
rich
.
print
(
feature
,
filename
,
year
)
citygmls
.
append
(
CityGMLWithDate
(
url
=
DOWNLOAD_SERVER
+
filename
,
bundesland
=
SACHSEN
,
# NOTE: No information is given about month or day, so assume end of year to be sure files get updated
source_date
=
datetime
(
year
,
12
,
31
),
# coordinate_reference_system ?
)
)
break
current_offset
+=
PAGE_SIZE
current_offset
+=
PAGE_SIZE
else
:
else
:
...
@@ -52,9 +101,4 @@ while keep_downloading:
...
@@ -52,9 +101,4 @@ while keep_downloading:
print
(
f
"❌ Error in response:
{
data
[
'error'
][
'message'
]
}
"
)
print
(
f
"❌ Error in response:
{
data
[
'error'
][
'message'
]
}
"
)
break
break
if
all_tiles
:
download_all_files
(
citygmls
)
df_tiles
=
pd
.
DataFrame
(
all_tiles
)
print
(
f
"
\n
✅ Final list contains
{
len
(
df_tiles
)
}
tiles."
)
print
(
df_tiles
.
describe
())
df_tiles
.
to_csv
(
"sachsen.csv"
)
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