윤영준 윤영준 2023-06-20
Added another example
@3c9c4eb285e8c91ef7911b210722893386d31719
 
example_GIS_marker.py (added)
+++ example_GIS_marker.py
@@ -0,0 +1,77 @@
+from choropleth import choropleth_chart
+from choropleth import plotly_fig2array
+import plotly.graph_objects as go
+import numpy as np
+import geopandas as gpd
+import pandas as pd
+import cv2
+
+def extract(lst, i):
+    return [item[i] for item in lst]
+
+def is_what(source, compare):
+    if compare in source:
+        return True
+    else:
+        return False
+
+shp = gpd.read_file('map/영천시 행정동.shp', encoding='utf-8')
+shp = shp.sort_values('EMD_KOR_NM')
+shp = shp.reset_index()
+
+df = np.linspace(0,15,num=16)
+
+address_book = pd.read_csv('data/영천시병원좌표.csv')
+
+color = ["#45E646"] * len(address_book['lat'])
+shape = ["circle"] * len(address_book['lat'])
+size = [12] * len(address_book['lat'])
+
+for i in range(len(color)):
+    name = address_book['병원명'][i]
+    if is_what(name, '보건소'):
+        color[i]="#FC5BC1"
+    elif is_what(name, '보건지소'):
+        color[i]="#9781DB"
+    elif is_what(name, '보건진료소'):
+        color[i]="#FC5B48"
+    elif is_what(name, '한의원'):
+        color[i]="#A85214"
+    elif is_what(name, '치과'):
+        color[i]="#94FFE8"
+
+for i in range(len(color)):
+    emergency= address_book["업무구분"][i]
+    if is_what(emergency, '지역응급의료기관'):
+        shape[i] = 'star-diamond'
+        size[i] = 20
+
+colorscale = [\
+    [0,'#FFEDCF'],
+    [0.33, '#F0CF2E'],
+    [0.57, '#F0FAA2'],
+    [1, '#F0CF2E']
+]
+
+fig = choropleth_chart(shp, df, '영천시 병원', 'figure/병원', geo_annot_scale=3000, colorscheme=colorscale, adaptive_legend_font_size=True, scale=5, save=False)
+fig.add_trace(
+    go.Scattergeo(
+        lat=address_book['lat'], lon=address_book['lon'],
+        marker=dict(
+            size= size,
+            color= color,
+            opacity= 0.6,
+            symbol=shape
+        ),
+        name="",
+        mode='markers',
+        text=address_book['병원명'],
+    )
+)
+fig.update(
+    layout_showlegend=True,
+    layout_coloraxis_showscale=False
+)
+scale = 4
+
+fig.show()(No newline at end of file)
Add a comment
List