-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_visualization.py
47 lines (30 loc) · 1.41 KB
/
data_visualization.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from email.mime import base
from bokeh.plotting import figure, save
from bokeh.models import ColumnDataSource, GeoJSONDataSource
import pandas as pd
import geopandas as gpd
def generate(shp_filename,nombre_destino):
base_map = r"./datos/datasets/INEGI_2010/estatal.shp"
population_dots = shp_filename
points_gdf = gpd.read_file(population_dots)
print(points_gdf.head)
base_map_gdf = gpd.read_file(base_map)
base_map_gdf.set_crs(epsg=6362, inplace=True)
print(base_map_gdf.crs)
base_map_gdf_correction = base_map_gdf.to_crs('epsg:4326')
print(base_map_gdf_correction)
points_to_plot_source = points_gdf[['LONGITUD','LATITUD']]
print(points_to_plot_source)
base_map_source = GeoJSONDataSource(geojson=base_map_gdf_correction.to_json())
p = figure(title="Mapa de cobertura",plot_height = 700 ,
plot_width = 1000,output_backend="webgl")
print(p)
p.multi_line('xs', 'ys', source=base_map_source, color='gray',
line_color = 'gray',
line_width = 2)
psource = ColumnDataSource(points_to_plot_source)
# Initialize our plot figure
# Add the points to the map from our 'psource' ColumnDataSource -object
p.circle('LONGITUD', 'LATITUD', source=psource, color='red', size=3)
outmap_route = "./maps/"+nombre_destino+".html"
save(obj=p, filename=outmap_route, title='Localidades dentro de Cobertura')