From 5a5140f38816d643d5cb2073afba79e61c51bccf Mon Sep 17 00:00:00 2001 From: Colm McDonald <55803987+G21-Goose@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:39:14 +0100 Subject: [PATCH] Add buffer to coastline If only dilation was used, the sea goes over the perimeter, so buffer is used --- prettymaps/fetch.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prettymaps/fetch.py b/prettymaps/fetch.py index 28f8c1c..4191f30 100644 --- a/prettymaps/fetch.py +++ b/prettymaps/fetch.py @@ -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)