forked from flaxandteal/python-course-learn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
25 lines (18 loc) · 612 Bytes
/
utils.py
File metadata and controls
25 lines (18 loc) · 612 Bytes
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
import geopandas
import folium
from shapely.geometry import Point
def to_geo_dataframe(df):
"""Turn a carpark DataFrame into a GeoDataFrame."""
geometry = [Point(row['LONGITUDE'], row['LATITUDE']) for index, row in df.iterrows()]
gdf = geopandas.GeoDataFrame(df, geometry=geometry)
gdf.crs = {'init': 'epsg:4326'}
return gdf
def plot_gdf(filename, gdf):
"""Save an interactive map plot."""
map = folium.Map(
location=[54.6, -5.90],
zoom_start=10
)
carparks = folium.features.GeoJson(gdf)
map.add_children(carparks)
map.save(filename)