kj-9 / prettymaps

A small set of Python functions to draw pretty maps from OpenStreetMap data. Based on osmnx, matplotlib and shapely libraries.
GNU Affero General Public License v3.0
0 stars 0 forks source link

more rewriting old api #16

Open kj-9 opened 1 year ago

kj-9 commented 1 year ago

imports:

from .draw import Plot, PolygonPatch, create_background, draw_text, plot_gdf, plt
from .fetch import get_gdf, get_perimeter

can you rewrite?

kj-9 commented 1 year ago

crs is important especailly when you call buffer in shapely object. shapley does not know about units of distance: https://gis.stackexchange.com/questions/304914/python-shapely-intersection-with-buffer-in-meter

it was weird when I plot 4326 projected gdf of streets without width it was proper: image

but with gdf.geometry.buffer(1) applied, it is just circle and axis is messed: image

It appeared in crs:4326, buffering 1 unit means 1 degree in lat or lng, far more than 1 meter. (I don't know exact unit) If I buffer(0.00001): image

kj-9 commented 1 year ago

That's why original implementation, before plotting, prettymap projects each gdf in utm. (which is default behaviour of ox.project_gdf)

in utm 1 unit is 1 meter.

kj-9 commented 1 year ago

need to refactor function args: https://github.com/kj-9/prettymaps/actions/runs/5589272216/jobs/10217297818#step:6:35

kj-9 commented 1 year ago

feels like width in layer parameter should be in styles parameter. https://github.com/kj-9/prettymaps/blob/123e347ac5783bf74a02a532fe2e89b1ee8b094d/prettymaps/new_api/plot.py#L335

this needs presets to be rewritten.

kj-9 commented 1 year ago

Integration tests should cover more presets (or map styles). There is feature which does not cover one preset.

Can be introduce test coverage soon.

kj-9 commented 1 year ago

see here for pytest-regressions parameterized: https://pytest-regressions.readthedocs.io/en/latest/overview.html#parametrized-tests

kj-9 commented 1 year ago

can we test this? np.random.choice(palette)

by setting seeds?