I had a go at doing roughly the same thing a couple of years ago [0]. It was mostly straightforward, but the part I really struggled with were rendering the sea. The encoding of OSM coastline is quite quirky [1]. When the edge of the rendering intersects with the coastline it's very tricky to compute which side of a coastline is sea and which is land. As an example - how would you render this [2]?
I wasn't sure how I could solve this, so I wrote up a more abstract formulation of the problem here [3], and asked for help. I think the proposed solution make sense, but I think I would have to implement it by rendering individual pixels and wouldn't be able to lean on a higher level graphics library.
I'm looking forward to seeing how the author solved this problem.
You might want to look into OSMCoastline, a separate piece of software written specifically to make the coastline usable for renders: https://osmcode.org/osmcoastline/
A simple solution is paint the sea with triangles of which one side is perfectly horizontal. And always work bottom to top.
You will have to pre scan the ways for instance where they change from ascending to descending. Here the sea will spilt into a left and right section. Make a list of these and sort them from top to bottom.
While generating triangles, check that list to where you should split.
Agreed. This is a good library but it is let down by lack of documentation. Reading the source doesn't help, e.g. this is "explaining" the parameters in the plot function:
# Whether to use a backup for the layers
backup = None,
# Custom postprocessing function on layers
postprocessing = None,
# Radius (in case of circular plot)
radius = None,
These sorts of comments merely repeat what's in the code and are worse than useless.
Knowledge, and capability are like the surface of a balloon. Each day the balloon is expanded and it is only after a while you realise how far away from the surface point you are on, all the other surface points have reached. I mean i toyed with python and maps back in the day, and my intuition for how good looking you could make one of these is completely off.
This stuff is amazing.
I think I want there to be a professional software "continuing-education" [#] service. A course I do each 6 months that just gets me to run something for an hour (from astronomy to 3d-printing).
I know i could do it myself but the 10 -20 hours spent on each install wasted though bad configs seems something I would happily pay to avoid.
[#] Not a "re-education" camp. Although I know few devs I could send to one if someone provides seed funding. ;-)
Add these imports to the top of the readme example to make it work. For the life of me I don't understand people who strip imports out of code examples.
import matplotlib.pyplot as plt
from prettymaps import plot
Looks really nice. The big blob of parameters in the kwargs looks pretty intimidating to get correct. Maybe consider a builder object for the config: https://en.wikipedia.org/wiki/Builder_pattern. It would probably be easier to document, too (document the setter methods of the Builder rather than try to explain the nested dict). Feel free to ignore me.
The option of not just setting a fixed colour for certain features (like a building), but supplying a palette of colours for the renderer to randomly use is interesting. It makes the output playful. I don't think I've seen that feature before in OpenStreetMap renderers.
Have you thought about building a site where users could order framed posters of any address they like using the output of this library? I think that would be cool
It's fun to see a fresh new take on how to draw maps in Python. I'm still mired in 10 year old concepts from when this stuff was much harder. This project just looks joyful.
Does anyone have a simple way to make rendered images from osm data? Usually it involves postgres, but I wish there was a renderer that could use the vector tiles directly...
the tricky part is to known which xtile, ytile to fetch, but Stack Overflow has the answer [1].
Then you can draw over them with `PIL` and also `cairo`, in order to lay SVG shapes onto the map. Cairo is somewhat hard to grasp, because it is outdated, but it draws perfectly smooth lines.
OSMs source of truth is not organized around vector tiles, i believe.
https://github.com/dfyz/osm-renderer might be similar to what you are looking for
Beautiful. I wish there was a way to simplify OSM roads. For example, southbound/northbound highways are correctly stored as separate roads in OSM. But to draw an atlas, it's often enough to show the single highway.
[+] [-] willsewell|4 years ago|reply
I had a go at doing roughly the same thing a couple of years ago [0]. It was mostly straightforward, but the part I really struggled with were rendering the sea. The encoding of OSM coastline is quite quirky [1]. When the edge of the rendering intersects with the coastline it's very tricky to compute which side of a coastline is sea and which is land. As an example - how would you render this [2]?
I wasn't sure how I could solve this, so I wrote up a more abstract formulation of the problem here [3], and asked for help. I think the proposed solution make sense, but I think I would have to implement it by rendering individual pixels and wouldn't be able to lean on a higher level graphics library.
I'm looking forward to seeing how the author solved this problem.
[0] https://twitter.com/willsewell_/status/1172523752699113473
[1] https://wiki.openstreetmap.org/wiki/Tag:natural%3Dcoastline#...
[2] https://www.openstreetmap.org/#map=15/22.0330/88.8819
[3] https://leetcode.com/discuss/general-discussion/1104642/im-s...
[+] [-] dabreegster|4 years ago|reply
[+] [-] simon04|4 years ago|reply
[+] [-] nroets|4 years ago|reply
You will have to pre scan the ways for instance where they change from ascending to descending. Here the sea will spilt into a left and right section. Make a list of these and sort them from top to bottom.
While generating triangles, check that list to where you should split.
[+] [-] mistrial9|4 years ago|reply
[+] [-] avnigo|4 years ago|reply
I was hoping for some more documentation apart from the usage examples, although those are much appreciated too.
[+] [-] cabalamat|4 years ago|reply
Agreed. This is a good library but it is let down by lack of documentation. Reading the source doesn't help, e.g. this is "explaining" the parameters in the plot function:
These sorts of comments merely repeat what's in the code and are worse than useless.[+] [-] ahmedbaracat|4 years ago|reply
[+] [-] lifeisstillgood|4 years ago|reply
This stuff is amazing.
I think I want there to be a professional software "continuing-education" [#] service. A course I do each 6 months that just gets me to run something for an hour (from astronomy to 3d-printing).
I know i could do it myself but the 10 -20 hours spent on each install wasted though bad configs seems something I would happily pay to avoid.
[#] Not a "re-education" camp. Although I know few devs I could send to one if someone provides seed funding. ;-)
[+] [-] killingtime74|4 years ago|reply
[+] [-] TekMol|4 years ago|reply
[+] [-] nightpool|4 years ago|reply
[+] [-] myidealab|4 years ago|reply
[+] [-] martinky24|4 years ago|reply
[deleted]
[+] [-] mdoms|4 years ago|reply
[+] [-] SundaySetUp|4 years ago|reply
[+] [-] pgroves|4 years ago|reply
[+] [-] pjot|4 years ago|reply
[0]: https://github.com/gboeing/osmnx
[+] [-] Freak_NL|4 years ago|reply
[+] [-] anigbrowl|4 years ago|reply
[+] [-] twoslide|4 years ago|reply
[+] [-] jimjimjimjim|4 years ago|reply
[+] [-] maddimini|4 years ago|reply
[+] [-] switch007|4 years ago|reply
[+] [-] mtmail|4 years ago|reply
[+] [-] adamhp|4 years ago|reply
[+] [-] amcaskill|4 years ago|reply
[+] [-] hasmanean|4 years ago|reply
Maybe a marketplace for such maps would allow artists to document their cities/neighborhoods.
[+] [-] unknown|4 years ago|reply
[deleted]
[+] [-] NelsonMinar|4 years ago|reply
[+] [-] agencies|4 years ago|reply
[+] [-] mtmail|4 years ago|reply
[+] [-] qwertox|4 years ago|reply
Then you can draw over them with `PIL` and also `cairo`, in order to lay SVG shapes onto the map. Cairo is somewhat hard to grasp, because it is outdated, but it draws perfectly smooth lines.
[1] https://stackoverflow.com/a/28530369
[+] [-] nielsole|4 years ago|reply
[+] [-] mistrial9|4 years ago|reply
[+] [-] swah|4 years ago|reply
[+] [-] smnrchrds|4 years ago|reply
[+] [-] maxerickson|4 years ago|reply
[+] [-] wiredfool|4 years ago|reply
[+] [-] donalhunt|4 years ago|reply
See https://www.openstreetmap.org/copyright
[+] [-] jfoucher|4 years ago|reply
[+] [-] pasabagi|4 years ago|reply
[+] [-] bhelkey|4 years ago|reply
[+] [-] nathancahill|4 years ago|reply
[+] [-] maxerickson|4 years ago|reply
[+] [-] humanistbot|4 years ago|reply
[+] [-] kingofpandora|4 years ago|reply