Abdishakur
1 min readOct 19, 2019

--

If you already have coordinates of the boundary you can easily make shapefile in Python. If you don’t have them, just go to Google Maps and find out the corners of the boundary.

Once you have all corner coordinates. I have created a function that takes coordinates and returns a Geodataframe.

import geopandas as gpd
import pandas as pd
from shapely.geometry import Point, Polygon
import folium
coordinates = [(4.812267, 52.328369), (4.823540, 52.456206), (5.050146, 52.458870), (5.081713, 52.317657)]
def create_polygon(coords, polygon_name):
“”” Create a polygon from coordinates”””
polygon = Polygon(coordinates)
gdf = gpd.GeoDataFrame(crs = {‘init’ :’epsg:4326'})
gdf.loc[0,’name’] = polygon_name
gdf.loc[0, ‘geometry’] = polygon
return gdf
shapefile = create_polygon(coordinates, “Amesterdam”)# Export to shapefile if you want
shapefile.to_file("myboundary.shp")

Here is a map with the polygon boundaries we have created.

Hope this helps you.

--

--

Abdishakur
Abdishakur

Written by Abdishakur

Writing about Geospatial Data Science, AI, ML, DL, Python, SQL, GIS | Top writer | 1m views.

No responses yet