Add buffer to coastline

If only dilation was used, the sea goes over the perimeter, so buffer is used
pull/47/head
Colm McDonald 2021-08-31 22:39:14 +01:00
rodzic 577bd33393
commit 5a5140f388
1 zmienionych plików z 4 dodań i 3 usunięć

Wyświetl plik

@ -28,19 +28,20 @@ def get_perimeter(query, by_osmid = False, **kwargs):
return ox.geocode_to_gdf(query, by_osmid = by_osmid, **kwargs, **{x: kwargs[x] for x in ['circle', 'dilate'] if x in kwargs.keys()})
# Get coastline
def get_coast(perimeter = None, point = None, radius = None, tags = {}, perimeter_tolerance = 0, union = True, circle = True, dilate = 0, file_location = None):
def get_coast(perimeter = None, point = None, radius = None, perimeter_tolerance = 0, union = True, buffer = 0, circle = True, dilate = 0, file_location = None):
if perimeter is not None:
# Boundary defined by polygon (perimeter)
bbox=perimeter.to_crs(3174)
bbox=bbox.buffer(perimeter_tolerance+dilate)
bbox=bbox.buffer(perimeter_tolerance+dilate+buffer)
bbox=bbox.to_crs(4326)
bbox=bbox.envelope
# Load the polygons for the coastline from a file
geometries = read_file(file_location, bbox=bbox)
perimeter = unary_union(ox.project_gdf(perimeter).geometry)
elif (point is not None) and (radius is not None):
# Boundary defined by circle with radius 'radius' around point
north,south,west,east=utils_geo.bbox_from_point(point, dist=radius+dilate)
north,south,west,east=utils_geo.bbox_from_point(point, dist=radius+dilate+buffer)
bbox=(west,south,east,north)
# Load the polygons for the coastline from a file
geometries=read_file(file_location, bbox=bbox)