Skip to content

Commit e4de1a7

Browse files
urbanization mdim bug: drop map tab in grouped locations (#5709)
1 parent 5255f88 commit e4de1a7

File tree

1 file changed

+30
-36
lines changed

1 file changed

+30
-36
lines changed

etl/steps/export/multidim/urbanization/latest/cities_towns_rural_areas.py

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -141,38 +141,32 @@ def run() -> None:
141141
view.config["title"] = metadata.get("title", "")
142142
view.config["subtitle"] = metadata.get("description_short", "")
143143

144-
# Set stacked area chart config for grouped location views
145-
if location_type == "location_type_stacked":
144+
# Set config for grouped location views (stacked and urban vs rural)
145+
if location_type in ["location_type_stacked", "urban_vs_rural"]:
146146
view.config = view.config.copy() if view.config else {}
147147

148-
# Add metadata for stacked views
149-
metadata = create_stacked_metadata(metric, data_type)
150-
view.metadata = metadata
151-
view.config["title"] = metadata["title"]
152-
view.config["subtitle"] = metadata["description_short"]
153-
154-
# Only set stack mode if metric dimension exists
155-
if metric:
148+
# Disable map tab for grouped location views
149+
view.config["hasMapTab"] = False
150+
view.config["tab"] = "chart"
151+
if "map" in view.config:
152+
del view.config["map"]
153+
154+
# Add metadata based on location type
155+
if location_type == "location_type_stacked":
156+
metadata = create_stacked_metadata(metric, data_type)
157+
else: # urban_vs_rural
158+
metadata = create_urban_vs_rural_metadata(metric, data_type)
159+
# Special config for popshare (0-100%)
156160
if metric == "popshare":
157-
view.config["stackMode"] = "relative"
158161
view.config["yAxis"] = {"min": 0, "max": 100}
159-
else:
160-
view.config["stackMode"] = "absolute"
162+
view.config["selectedFacetStrategy"] = "entity"
161163

162-
# Set config for urban vs rural line chart views
163-
if location_type == "urban_vs_rural":
164-
view.config = view.config.copy() if view.config else {}
164+
view.config["yAxis"] = {"facetDomain": "independent"}
165165

166-
# Add metadata for urban vs rural views
167-
metadata = create_urban_vs_rural_metadata(metric, data_type)
168166
view.metadata = metadata
169167
view.config["title"] = metadata["title"]
170168
view.config["subtitle"] = metadata["description_short"]
171169

172-
# Special config for popshare (0-100%)
173-
if metric == "popshare":
174-
view.config["yAxis"] = {"min": 0, "max": 100}
175-
176170
# Map-only view for dominant settlement type
177171
if metric == "dominant_type":
178172
view.config = view.config.copy() if view.config else {}
@@ -245,27 +239,27 @@ def create_stacked_metadata(metric, data_type):
245239
(
246240
"population",
247241
"estimates",
248-
): "Estimated number of people living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
242+
): "Estimated number of people living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
249243
(
250244
"population",
251245
"projections",
252-
): "Projected number of people living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
246+
): "Projected number of people living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
253247
(
254248
"population",
255249
"estimates_and_projections",
256-
): "Number of people living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
250+
): "Number of people living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
257251
(
258252
"popshare",
259253
"estimates",
260-
): "Estimated share of population living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
254+
): "Estimated share of population living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
261255
(
262256
"popshare",
263257
"projections",
264-
): "Projected share of population living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
258+
): "Projected share of population living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
265259
(
266260
"popshare",
267261
"estimates_and_projections",
268-
): "Share of population living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
262+
): "Share of population living in [cities](#dod:cities-degurba), [towns and suburbs](#dod:towns-degurba), and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
269263
}
270264

271265
# Define description_key - same for all data types
@@ -322,27 +316,27 @@ def create_urban_vs_rural_metadata(metric, data_type):
322316
(
323317
"population",
324318
"estimates",
325-
): "Estimated number of people living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
319+
): "Estimated number of people living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
326320
(
327321
"population",
328322
"projections",
329-
): "Projected number of people living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
323+
): "Projected number of people living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
330324
(
331325
"population",
332326
"estimates_and_projections",
333-
): "Number of people living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
327+
): "Number of people living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
334328
(
335329
"popshare",
336330
"estimates",
337-
): "Estimated share of population living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
331+
): "Estimated share of population living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
338332
(
339333
"popshare",
340334
"projections",
341-
): "Projected share of population living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
335+
): "Projected share of population living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
342336
(
343337
"popshare",
344338
"estimates_and_projections",
345-
): "Share of population living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba). Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries.",
339+
): "Share of population living in urban areas ([cities](#dod:cities-degurba) and [towns and suburbs](#dod:towns-degurba) combined) and [rural areas](#dod:rural-areas-degurba), based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country.",
346340
}
347341

348342
# Define description_key - same for all data types
@@ -407,7 +401,7 @@ def create_individual_view_metadata(location_type, metric, data_type):
407401
if metric == "dominant_type":
408402
description_short = (
409403
metric_descriptions[metric]
410-
+ ". Settlement types are identified using satellite imagery and population data, applying the same density and size thresholds across all countries."
404+
+ ", based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country."
411405
)
412406
else:
413407
metric_text = metric_descriptions.get(metric, "")
@@ -421,7 +415,7 @@ def create_individual_view_metadata(location_type, metric, data_type):
421415
else:
422416
description_short += ", measured in percentage points. Positive values indicate a growing share; negative values indicate a declining share"
423417

424-
description_short += ", identified using satellite imagery and population data, applying the same density and size thresholds across all countries."
418+
description_short += ", based on a harmonized definition that uses satellite imagery and population data to apply the same density and settlement-size thresholds in every country."
425419

426420
title = _individual_title(location_type, metric, data_type)
427421

0 commit comments

Comments
 (0)