prettymaps
prettymaps copied to clipboard
Parts of water not mapped properly
Boston (river) and Lisbon (part of the ocean) are not recognized as water.
As in my other issue: Using a slightly modified version of the circular example with a radius of 2500.
I used this to get some of the areas with water in Boston. The area that is missing seems to be bounded by coastline
. I imagine this will be the same with Lisbon
'water': {
'tags':{
'waterway': True,
'water': True,
'harbour': True,
'marina': True,
'bay': True,
'river': True
},
},
Currently coastlines won't work, but my pull request here #47 should work for you. In order for it to work you need to download and extract a .shp
file from here and set file_location
to point to the .shp
file in the coastline
layer.
You can make this with:
from prettymaps import *
from matplotlib import pyplot as plt
dilate = 100
circle=False
# Setup figure
figsize=(10,10)
fig, ax = plt.subplots(figsize = figsize, constrained_layout = True)
# Plot
layers = plot(
(42.36, -71.0584), radius = 10000,
ax = ax,
layers = {
'perimeter': {'circle': circle, 'dilate': dilate},
'water': {
'tags':{
'waterway': True,
'water': True,
'harbour': True,
'marina': True,
'bay': True,
'river': True
},
'dilate':dilate,
'circle': circle,
},
'coastline':{
'file_location':'./OSMdata/water-polygons-split-4326/water-polygons-split-4326/water_polygons.shp',
'buffer':100000,
'circle':circle
},
},
drawing_kwargs = {
'background': {'fc': '#F2F4CB', 'ec': '#dadbc1', 'hatch': 'ooo...', 'zorder': -1},
'perimeter': {'fill': False, 'ec': '#000000', 'lw': 0.5, 'zorder': 0},
'water': {'fc': '#a8e1e6', 'ec': '#2F3737', 'hatch_c': '#9bc3d4', 'hatch': 'ooo...', 'lw': 1, 'zorder': 1},
'coastline': {'fc': '#a8e1e6', 'ec': '#2F3737', 'hatch_c': '#9bc3d4', 'hatch': 'ooo...', 'lw': 1, 'zorder': 2}
},
osm_credit = {'x': .02, 'y': .01, 'color': '#2F3737'}
)
# Set bounds
xmin, ymin, xmax, ymax = layers['perimeter'].bounds
dx, dy = xmax-xmin, ymax-ymin
ax.set_xlim(xmin-.06*dx, xmax+.06*dx)
ax.set_ylim(ymin-.06*dy, ymax+.02*dy)
plt.savefig('./prints/boston.png')
plt.savefig('./prints/boston.svg')
Hi there,
In the current version (as of dec 2022), I am not able to correctly display some coastlines. For instance stockholm
isn't correctly displayed.
https://www.openstreetmap.org/search?query=stockholm#map=15/59.3245/18.0779 (I think that on the left of the island is a lake and on the right the sea)
Attempt 1
import prettymaps
plot = prettymaps.plot(
query='Stockholm',
radius=1500,
circle=False,
dilate=False,
credit=False,
layers={
'coastline': {
'tags': {
'natural': 'coastline'
},
},
'water': {
'width': 1,
'buffer': 3000,
'retain_all': True,
'tags': {
'natural': ['water', 'bay', 'waterway', 'harbour', 'marina', 'strait', 'river', 'wetland']
}
}
},
style={
'water': {
'fc': '#a8e1e6',
'ec': '#2F3737',
'hatch_c': '#9bc3d4',
'hatch': 'ooo...',
'lw': 1,
'zorder': 3
},
'coastline': {
'fc': '#a8e1e6',
'ec': '#2F3737',
'hatch_c': '#9bc3d4',
'hatch': 'ooo...',
'lw': 1,
'zorder': 3
}
},
)
plot.fig.savefig('test.png')
It produces this image
Attempt 2 with proposed hack (everything is the same except the coastline layer:
'coastline':{
'file_location': './assets/water_polygons.shp',
'buffer':100000,
'circle':False
},
It fails
Traceback (most recent call last): File "./test.py", line 3, in
plot = prettymaps.plot( File "./env/src/prettymaps/prettymaps/draw.py", line 897, in plot gdfs = get_gdfs(query, layers, radius, dilate, -rotation) File "./env/src/prettymaps/prettymaps/fetch.py", line 225, in get_gdfs gdfs.update({ File "./env/src/prettymaps/prettymaps/fetch.py", line 226, in layer: get_gdf(layer, perimeter, **kwargs) File "./env/src/prettymaps/prettymaps/fetch.py", line 186, in get_gdf gdf = ox.geometries_from_polygon( File "./env/lib/python3.9/site-packages/osmnx/geometries.py", line 278, in geometries_from_polygon response_jsons = downloader._osm_geometries_download(polygon, tags) File "./env/lib/python3.9/site-packages/osmnx/downloader.py", line 583, in _osm_geometries_download query_str = _create_overpass_query(polygon_coord_str, tags) File "./env/lib/python3.9/site-packages/osmnx/downloader.py", line 461, in _create_overpass_query raise TypeError(error_msg) TypeError: tags must be a dict with values of bool, str, or list of str
I'm having the same issue. have you figured this out yet?
@BearPawwz, no sorry, I just gave up for now