Skip to content
Snippets Groups Projects
Commit a7739fca authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

update: return only polygons

parent 911cb264
No related branches found
No related tags found
1 merge request!3Choropleth map implementation
......@@ -7,8 +7,6 @@ from APIs.get_weather import get_weather
import ssl
import keyboard
import sqlite3
import geopandas as gpd
import matplotlib.pyplot as plt
app = Flask(__name__)
......@@ -67,19 +65,6 @@ def on_key_press(server, event, cursor, conn):
# Start a server on port 8443 using self defined HTTP class
if __name__ == "__main__":
# Load GeoJSON data using geopandas
geo_data = gpd.read_file("server/map/mjosa.geojson")
# Filter only polygons
polygon_data = geo_data[geo_data['geometry'].geom_type == 'Polygon']
# Plot polygons
polygon_data.plot()
plt.title('Polygons in Mjøsa GeoJSON')
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.show()
try:
# Initialize database connection
conn = sqlite3.connect('server/sql_db/icedb')
......
No preview for this file type
import string
import json
import geopandas as gpd
import matplotlib.pyplot as plt
# get_relation returns the geojson data for a selected body of water
def get_relation(self, body_of_water: string):
# Read geojson file
with open("server/map/" + body_of_water.lower() + ".geojson") as f:
data = json.load(f)
# Load GeoJSON data using geopandas
geo_data = gpd.read_file("server/map/mjosa.geojson")
# Filter only polygons
polygon_data = geo_data[geo_data['geometry'].geom_type == 'Polygon']
# Plot polygons
polygon_data.plot()
plt.title('Polygons in Mjøsa GeoJSON')
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.show()
# Convert GeoDataFrame to GeoJSON-like dictionary
geojson_dict = json.loads(polygon_data.to_json())
# Convert response data to JSON string
response_json = json.dumps(data)
response_json = json.dumps(geojson_dict)
# Set headers
self.send_response(200)
......
import geopandas as gpd
import matplotlib.pyplot as plt
def map_test():
# Load GeoJSON data using geopandas
geo_data = gpd.read_file("mjosa.geojson")
# Plot choropleth map
geo_data.plot()
plt.title('Choropleth Map of Mjøsa Lake')
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.show()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment