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
bd4bfec8
Commit
bd4bfec8
authored
Jan 27, 2022
by
Simantini Shinde
Browse files
Removed calculate_district_area
parent
7ea49252
Pipeline
#37850
passed with stage
in 1 minute and 37 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
exposurejapan/database.py
View file @
bd4bfec8
...
...
@@ -1026,41 +1026,6 @@ class JapanDatabase(SpatialiteDatabase):
return
polygon
.
area
def
calculate_district_area
(
self
):
"""
Selects all districts (i.e. administrative units) and their geometry from District
table and calculates the unit area for each district and stores it in a list.
Returns:
list:
List with districts, their geometries and their unit areas.
"""
# Select the district_id and geometry from District table
sql_statement
=
"SELECT id, AsWKT(CastAutomagic(geom)) FROM District"
self
.
cursor
.
execute
(
sql_statement
)
# Create an empty list to store the districts and their unit areas
districts
=
[]
# Store all districts and their geometry in a list
for
row
in
self
.
cursor
:
add_element_and_get_index
(
row
,
districts
)
# Calculate the district area and add it to the districts list.
for
row
in
districts
:
admin_unit_geom
=
shapely
.
wkt
.
loads
(
row
[
1
])
administrative_unit_area
=
(
self
.
albers_area_calculation
(
admin_unit_geom
,
"epsg: %d"
)
%
constants
.
JGD2000
*
0.000001
)
#
# Convert to square kilometers
index
=
districts
.
index
(
row
)
districts
[
index
]
=
row
+
(
administrative_unit_area
,)
numpy
.
seterr
(
divide
=
"ignore"
,
invalid
=
"ignore"
)
return
districts
def
import_population_distribution
(
self
,
population_distribution_filepath
):
"""
Imports all population data from the 2015 Population Census file provided
...
...
@@ -1167,8 +1132,12 @@ class JapanDatabase(SpatialiteDatabase):
"6_150m2 and over"
,
]
# Select the district_id and area_size from District table
sql_statement
=
"SELECT id, area_size FROM District"
self
.
cursor
.
execute
(
sql_statement
)
# Store all district (i.e. administrative unit) areas with their district_ids in a list
districts
=
self
.
c
alculate_district_area
()
districts
=
self
.
c
ursor
.
fetchall
()
# Import population data into the database
self
.
import_population_distribution
(
population_distribution_filepath
)
...
...
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