Update app.py
Browse files
app.py
CHANGED
|
@@ -34,9 +34,49 @@ def getCountrycode(land, level):
|
|
| 34 |
|
| 35 |
blub = gdf.iloc[0]
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
# Gradio
|
| 42 |
import gradio as gr
|
|
|
|
| 34 |
|
| 35 |
blub = gdf.iloc[0]
|
| 36 |
|
| 37 |
+
import pandas as pd
|
| 38 |
+
def getLand(landnr):
|
| 39 |
+
|
| 40 |
+
#Test
|
| 41 |
+
data = {'GID_1': ['DEU.1_1','DEU.2_1'],
|
| 42 |
+
'GID_0': ['DEU', 'DEU'],
|
| 43 |
+
'COUNTRY': ['Germany', 'Germany'],
|
| 44 |
+
'NAME_1': ['Baden-Würtenberg', 'Bayern'],
|
| 45 |
+
'VARNAME_1': ['NA','Bavaria'],
|
| 46 |
+
'NL_NAME_1': ['NA', 'NA'],
|
| 47 |
+
'TYPE_1': ['Land', 'Freistaat'],
|
| 48 |
+
'ENGTYPE_1': ['State', 'Freestate'],
|
| 49 |
+
'CC_1': ['08','09'],
|
| 50 |
+
'HASC_1': ['DE.BW', 'DE.BY'], # Extra for subnational countys (https://de.wikipedia.org/wiki/Hierarchical_administrative_subdivision_codes)
|
| 51 |
+
'ISO_1': ['NA', 'DE-BY'], # International Order --> Check First (https://de.wikipedia.org/wiki/ISO_3166)
|
| 52 |
+
'geometry': [0,1]
|
| 53 |
+
}
|
| 54 |
+
gdf = pd.DataFrame(data)
|
| 55 |
+
landR = gdf.iloc[landnr]
|
| 56 |
+
#print(landR)
|
| 57 |
+
return landR
|
| 58 |
+
|
| 59 |
+
# function to generate output
|
| 60 |
+
# Land should be a line from the geojson-table
|
| 61 |
+
# Currently only works for NUTS-1 areas!!!
|
| 62 |
+
|
| 63 |
+
def getCountrycode(land, level = 1):
|
| 64 |
+
|
| 65 |
+
iso = 'ISO_'+ str(level)
|
| 66 |
+
hasc = 'HASC_' + str(level)
|
| 67 |
+
if land[iso] != 'NA':
|
| 68 |
+
return str(land[iso])
|
| 69 |
+
elif land[hasc]:
|
| 70 |
+
return str(land[hasc])
|
| 71 |
+
else:
|
| 72 |
+
return False
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def grad_Country(landnr):
|
| 76 |
+
landnr = int(landnr)
|
| 77 |
+
land = getLand(int(landnr))
|
| 78 |
+
kuerzel = getCountrycode(land)
|
| 79 |
+
return str(kuerzel)
|
| 80 |
|
| 81 |
# Gradio
|
| 82 |
import gradio as gr
|