jeme213 commited on
Commit
76f2dc1
·
1 Parent(s): 0304ca7

Geojons funktionieren jetzt

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -28,12 +28,17 @@ def AskAI_easy(ques):
28
  fname = ''.join(char for char in str(ques) if char.isupper() or char.islower())
29
  blub = str(AskAI(ques,1,Tmain))
30
 
 
 
 
 
31
  row = eval(blub)[0]['coordinates'][0][0] #get object
32
  out_df = Tmain.iloc[row,:12]
33
- out_df['geom'] = Tgeom.iloc[row,0]
34
- geojson_string = out_df.to_json(orient='index')
35
- #out_gdf = gpd.GeoDataFrame(out_df, geometry = 'geom') # funktioniert nicht --> Geometrie ist kaputt =(
36
- #geojson_string = out_gdf.to_json(driver='GeoJSON')
 
37
 
38
  # store File on GitHub
39
  from github import Github
@@ -41,14 +46,15 @@ def AskAI_easy(ques):
41
  github_user = "Giedeon25"
42
  github_repo = "GID-Project"
43
  token = "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"
 
44
  # using an access token
45
  auth = Auth.Token("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")
46
  # First create a Github instance:
47
  g = Github(auth=auth)
48
 
49
  repo = g.get_repo("Giedeon25/GID-Project")
50
- repo.create_file("data/Output/" + fname + ".json", "committing files", geojson_string, branch="main") # create File
51
-
52
  return(blub + " ==== " + "dllink: https://github.com/Giedeon25/GID-Project/blob/main/data/Output/" + fname + ".json")
53
 
54
 
 
28
  fname = ''.join(char for char in str(ques) if char.isupper() or char.islower())
29
  blub = str(AskAI(ques,1,Tmain))
30
 
31
+ # generate DL Links ###################################
32
+ # Geospatial Libraries
33
+ import geopandas as gpd
34
+ from shapely.wkt import loads
35
  row = eval(blub)[0]['coordinates'][0][0] #get object
36
  out_df = Tmain.iloc[row,:12]
37
+ out_df['geometry'] = Tgeom.iloc[row,1]
38
+ geometry_wkt = out_df['geometry']
39
+ geometry = loads(geometry_wkt)
40
+ out_gdf = gpd.GeoDataFrame(geometry=[geometry]) #
41
+ geojson_string = out_gdf.to_json()
42
 
43
  # store File on GitHub
44
  from github import Github
 
46
  github_user = "Giedeon25"
47
  github_repo = "GID-Project"
48
  token = "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"
49
+
50
  # using an access token
51
  auth = Auth.Token("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")
52
  # First create a Github instance:
53
  g = Github(auth=auth)
54
 
55
  repo = g.get_repo("Giedeon25/GID-Project")
56
+ repo.create_file("data/Output/" + fname + ".json", "committing file", geojson_string, branch="main") # create File
57
+
58
  return(blub + " ==== " + "dllink: https://github.com/Giedeon25/GID-Project/blob/main/data/Output/" + fname + ".json")
59
 
60