Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
Get Baden-Württemberg CityGML Opendata
Commits
aad32b55
Commit
aad32b55
authored
6 months ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Seems to work with Multipolygon again
parent
34a11f74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
download_files_from_LGL_BW.py
+15
-2
download_files_from_LGL_BW.py
with
15 additions
and
2 deletions
+15
-2
download_files_from_LGL_BW.py
+
15
-
2
View file @
aad32b55
...
...
@@ -21,10 +21,13 @@ import re
import
urllib.request
import
time
import
zipfile
import
re
from
pyproj
import
CRS
from
pyproj
import
Transformer
COORDINATES_REGEX
=
re
.
compile
(
r
"(\-?\d+\.\d*) (\-?\d+\.\d*)"
)
###### User input ##########
POLYGONS
=
{
"StuttgartCenter"
:
"POLYGON((9.175287 48.780916, 9.185501 48.777522, 9.181467 48.773704, 9.174429 48.768472, 9.168807 48.773902, 9.175287 48.780916))"
,
...
...
@@ -133,9 +136,11 @@ def extract_region(output_dir: Path, location_name: str, wkt: str) -> None:
params_path
=
output_dir
/
'params.txt'
wkt_path
=
output_dir
/
'region.wkt'
local_wkt
=
convert_wkt_to_local
(
wkt
)
print
(
f
" Extracting
{
output_file
}
."
)
with
open
(
wkt_path
,
'w'
)
as
f
:
f
.
write
(
wkt
)
f
.
write
(
local_
wkt
)
with
open
(
params_path
,
'w'
)
as
f
:
f
.
write
(
"--input
\n
"
)
...
...
@@ -143,6 +148,7 @@ def extract_region(output_dir: Path, location_name: str, wkt: str) -> None:
f
.
write
(
"
\n
"
)
f
.
write
(
"--output
\n
"
)
f
.
write
(
f
'"
{
output_file
}
"
\n
'
)
f
.
write
(
'--local
\n
'
)
f
.
write
(
"--wkt
\n
"
)
f
.
write
(
f
'"
{
wkt_path
}
"
\n
'
)
...
...
@@ -154,7 +160,6 @@ def extract_region(output_dir: Path, location_name: str, wkt: str) -> None:
capture_output
=
True
)
if
(
result
.
stderr
):
print
(
"
\n
"
)
print
(
result
.
stderr
)
if
result
.
returncode
!=
0
:
raise
ValueError
(
f
"RegionChooser failed with code
{
result
.
returncode
}
"
)
...
...
@@ -174,6 +179,14 @@ def main(polygons: dict[str, str]) -> None:
extract_region
(
output_dir
,
location_name
,
wkt
)
print
()
def
show_coordinates
(
match
):
longitude
,
latitude
=
match
.
groups
()
transformer
=
Transformer
.
from_crs
(
WGS84
,
LOCAL_CRS
,
always_xy
=
True
)
x
,
y
=
transformer
.
transform
(
longitude
,
latitude
)
return
f
"
{
x
}
{
y
}
"
def
convert_wkt_to_local
(
wkt
):
return
COORDINATES_REGEX
.
sub
(
show_coordinates
,
wkt
)
if
__name__
==
'__main__'
:
main
(
POLYGONS
)
This diff is collapsed.
Click to expand it.
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