You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The width of lines is given as a fixed value of matplotlib "points" which means the width of a line stays the same regardless of the map size. In small maps the lines end up smaller and in large maps the lines end up so big you can't see anything.
I thought it would be nice to allow configuring the width of lines in meters. I'm not sure if doing so is in scope for this project or not, whether it would break things for people. If there would be an interest in having all the width configuration be in meters I'd be happy to open a PR to implement that, but otherwise I'd like to just leave the solution I wrote in case it's useful for anybody else.
This ended up generating reasonably looking small and large maps. When generating very large (radius >10km) maps it works when saving to svg, but the resolution ends up being too small when exporting to jpg or png without increasing the dpi.
from shapely import Point
from geopandas import GeoDataFrame
(
xmin,
ymin,
xmax,
ymax,
) = aoi.bounds
ymid = (ymin + ymax) / 2
# Width of the figure in matplotlib "points"
width_points = plot.fig.get_size_inches()[0] * 72
left_point = Point(xmin, ymid)
right_point = Point(xmax, ymid)
gdf = GeoDataFrame(geometry=[left_point, right_point], crs="EPSG:4326")
gdf = gdf.to_crs("EPSG:32633")
# This represents the (longitudal) distance (in meters) of the plot
# through the center of the plot.
#
# Should be equal to two times the radius.
width_meters = gdf.geometry.iloc[0].distance(gdf.geometry.iloc[1])
# The width in points of one meter (at the center of the plot)
meter_points = width_points / width_meters
for key in STREETS_WIDTH:
STREETS_WIDTH[key] *= meter_points
and also modify plotting.py to multiply by meter_points (at
The width of lines is given as a fixed value of matplotlib "points" which means the width of a line stays the same regardless of the map size. In small maps the lines end up smaller and in large maps the lines end up so big you can't see anything.
I thought it would be nice to allow configuring the width of lines in meters. I'm not sure if doing so is in scope for this project or not, whether it would break things for people. If there would be an interest in having all the width configuration be in meters I'd be happy to open a PR to implement that, but otherwise I'd like to just leave the solution I wrote in case it's useful for anybody else.
This ended up generating reasonably looking small and large maps. When generating very large (radius >10km) maps it works when saving to svg, but the resolution ends up being too small when exporting to jpg or png without increasing the dpi.
and also modify plotting.py to multiply by
meter_points
(atprettymapp/prettymapp/plotting.py
Line 126 in 3a6ef57
prettymapp/prettymapp/plotting.py
Line 146 in 3a6ef57
The text was updated successfully, but these errors were encountered: