|
12 | 12 | os.makedirs(OUTPUT_DIR, exist_ok=True) |
13 | 13 | os.makedirs(CACHE_DIR, exist_ok=True) |
14 | 14 |
|
15 | | -# Define the REST API URL |
16 | | -rest_api_url = "https://services.arcgis.com/iQ1dY19aHwbSDYIF/ArcGIS/rest/services/World_Bank_Global_Administrative_Divisions_VIEW/FeatureServer" |
| 15 | +# Define the REST API URLs |
| 16 | +rest_api_url_view = "https://services.arcgis.com/iQ1dY19aHwbSDYIF/ArcGIS/rest/services/World_Bank_Global_Administrative_Divisions_VIEW/FeatureServer" |
| 17 | +rest_api_url_new = "https://services.arcgis.com/iQ1dY19aHwbSDYIF/ArcGIS/rest/services/World_Bank_Global_Administrative_Divisions/FeatureServer" |
| 18 | + |
| 19 | +# Active service selection - Set to True to use new service, False for VIEW service |
| 20 | +USE_NEW_SERVICE = True |
| 21 | + |
| 22 | +# Set active URL based on service selection |
| 23 | +rest_api_url = rest_api_url_new if USE_NEW_SERVICE else rest_api_url_view |
| 24 | + |
17 | 25 | worldpop_url = "https://data.worldpop.org/GIS/Population/" |
18 | 26 | stac_search_url = "https://geoservice.dlr.de/eoc/ogc/stac/v1/search" |
19 | 27 |
|
20 | 28 |
|
21 | 29 | # Mapping of administrative levels to field names for WB GAD dataset |
22 | | -adm_field_mapping = { |
23 | | - 0: {'code': 'HASC_0', 'name': 'NAM_0'}, |
24 | | - 1: {'code': 'HASC_1', 'name': 'NAM_1'}, |
25 | | - 2: {'code': 'HASC_2', 'name': 'NAM_2'}, |
26 | | - # Add mappings for additional levels as needed |
27 | | -} |
| 30 | +# Field mapping adjusted based on active service |
| 31 | +if USE_NEW_SERVICE: |
| 32 | + adm_field_mapping = { |
| 33 | + 0: {'code': 'ISO_A3', 'name': 'NAM_0'}, # New service uses ISO_A3 instead of HASC_0 |
| 34 | + 1: {'code': 'ADM1CD_c', 'name': 'NAM_1'}, # New service uses ADM1CD_c instead of HASC_1 |
| 35 | + 2: {'code': 'ADM2CD_c', 'name': 'NAM_2'}, # New service uses ADM2CD_c instead of HASC_2 |
| 36 | + } |
| 37 | +else: |
| 38 | + adm_field_mapping = { |
| 39 | + 0: {'code': 'HASC_0', 'name': 'NAM_0'}, |
| 40 | + 1: {'code': 'HASC_1', 'name': 'NAM_1'}, |
| 41 | + 2: {'code': 'HASC_2', 'name': 'NAM_2'}, |
| 42 | + # Add mappings for additional levels as needed |
| 43 | + } |
28 | 44 |
|
29 | 45 | wb_to_region = { |
30 | 46 | 'AFR': 'AFRICA', # Sub-Saharan Africa |
|
0 commit comments