21 lines
650 B
Python
21 lines
650 B
Python
import folium
|
|
import geopandas as gpd
|
|
|
|
# Carregar o arquivo shapefile contendo a geometria
|
|
input_shapefile = 'LineFeature.shp'
|
|
data_geometry = gpd.read_file(input_shapefile)
|
|
|
|
# Calcular os limites (bounds) da geometria
|
|
minx, miny, maxx, maxy = data_geometry.total_bounds
|
|
center = [(miny + maxy) / 2, (minx + maxx) / 2]
|
|
|
|
# Criar um mapa centrado no centro das coordenadas das geometrias
|
|
m = folium.Map(location=center, zoom_start=12)
|
|
|
|
# Converter o GeoDataFrame para GeoJSON e adicionar ao mapa
|
|
geojson_data = data_geometry.to_json()
|
|
folium.GeoJson(geojson_data).add_to(m)
|
|
|
|
# Salvar o mapa interativo em um arquivo HTML
|
|
m.save('mapa_interativo.html')
|