Spaces:
Sleeping
Sleeping
File size: 1,065 Bytes
84e78bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import geopandas as gpd
# Sample DataFrame acording to actual structure (use your own data)
data = {'GID_1': ['DEU.1_1','DEU.2_1'],
'GID_0': ['DEU', 'DEU'],
'COUNTRY': ['Germany', 'Germany'],
'NAME_1': ['Baden-Würtenberg', 'Bayern'],
'VARNAME_1': ['NA','Bavaria'],
'NL_NAME_1': ['NA', 'NA'],
'TYPE_1': ['Land', 'Freistaat'],
'ENGTYPE_1': ['State', 'Freestate'],
'CC_1': ['08','09'],
'HASC_1': ['DE.BW', 'DE.BY'], # Extra for subnational countys (https://de.wikipedia.org/wiki/Hierarchical_administrative_subdivision_codes)
'ISO_1': ['NA', 'DE-BY'], # International Order --> Check First (https://de.wikipedia.org/wiki/ISO_3166)
'geometry': [0,1]
}
gdf = gpd.GeoDataFrame(data)
# function to generate output
# Land should be a line from the geojson-table
# Currently only works for NUTS-1 areas!!!
def getCountrycode(land):
if land['ISO_1'] != 'NA':
return land['ISO_1']
elif land['HASC_1']:
return land['HASC_1']
else:
return False
|