mirror of
https://github.com/marceloprates/prettymaps.git
synced 2025-08-21 13:52:39 +02:00
Add buffer to coastline
If only dilation was used, the sea goes over the perimeter, so buffer is used
This commit is contained in:
@@ -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()})
|
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
|
# 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:
|
if perimeter is not None:
|
||||||
# Boundary defined by polygon (perimeter)
|
# Boundary defined by polygon (perimeter)
|
||||||
bbox=perimeter.to_crs(3174)
|
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.to_crs(4326)
|
||||||
bbox=bbox.envelope
|
bbox=bbox.envelope
|
||||||
|
# Load the polygons for the coastline from a file
|
||||||
geometries = read_file(file_location, bbox=bbox)
|
geometries = read_file(file_location, bbox=bbox)
|
||||||
perimeter = unary_union(ox.project_gdf(perimeter).geometry)
|
perimeter = unary_union(ox.project_gdf(perimeter).geometry)
|
||||||
|
|
||||||
elif (point is not None) and (radius is not None):
|
elif (point is not None) and (radius is not None):
|
||||||
# Boundary defined by circle with radius 'radius' around point
|
# 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)
|
bbox=(west,south,east,north)
|
||||||
# Load the polygons for the coastline from a file
|
# Load the polygons for the coastline from a file
|
||||||
geometries=read_file(file_location, bbox=bbox)
|
geometries=read_file(file_location, bbox=bbox)
|
||||||
|
Reference in New Issue
Block a user