Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dynamic Exposure
Global Dynamic Exposure
exposure-japan
Commits
d47e6da1
Commit
d47e6da1
authored
Jan 27, 2022
by
Danijel Schorlemmer
Browse files
Changed the Shapely polygon creation from WKT to WKB to speed up the processing
parent
7afb795e
Pipeline
#37923
passed with stage
in 2 minutes and 4 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
exposurejapan/database.py
View file @
d47e6da1
...
...
@@ -22,6 +22,7 @@ import pandas
import
numpy
import
constants
import
shapely.wkt
import
shapely.wkb
import
pyproj
from
shapely.ops
import
transform
import
csv
...
...
@@ -634,11 +635,11 @@ class JapanDatabase(SpatialiteDatabase):
# Calculate the area for each district using Albers equal area transformation
# and update the Districts table
sql_statement
=
"SELECT id,
ST_AsText
(geom) FROM District"
sql_statement
=
"SELECT id,
AsBinary
(geom) FROM District"
self
.
cursor
.
execute
(
sql_statement
)
districts
=
self
.
cursor
.
fetchall
()
for
district
in
districts
:
district_geom
=
shapely
.
wk
t
.
loads
(
district
[
1
])
district_geom
=
shapely
.
wk
b
.
loads
(
district
[
1
])
district_size
=
(
self
.
albers_area_calculation
(
district_geom
,
"epsg:%d"
%
constants
.
WGS84
)
*
0.000001
# Convert from square meters to square kilometers
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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