makieorg / osmmakie.jl Goto Github PK
View Code? Open in Web Editor NEWA Makie.jl recipe for plotting OpenStreetMap data.
License: MIT License
A Makie.jl recipe for plotting OpenStreetMap data.
License: MIT License
I'm running the example code from the Readme file.
However, in the example downloading and displaying buildings, I am running into an error:
area = (
minlat = 51.5015, minlon = -0.0921, # bottom left corner
maxlat = 51.5154, maxlon = -0.0662 # top right corner
)
# download OpenStreetMap buildings data
download_osm_buildings(:bbox;
area...,
metadata = true,
download_format = :osm,
save_to_file_location = "london_buildings.osm",
);
# load as Buildings Dict
buildings = buildings_from_file("london_buildings.osm");
produces
ERROR: KeyError: key 5461892572 not found
Stacktrace:
[1] getindex(h::Dict{Int64, Dict{String, Any}}, key::Int64)
@ Base ./dict.jl:484
[2] parse_osm_buildings_dict(osm_buildings_dict::Dict{String, Any})
@ LightOSM ~/.julia/packages/LightOSM/Lf5Q0/src/buildings.jl:215
[3] buildings_from_object
@ ~/.julia/packages/LightOSM/Lf5Q0/src/buildings.jl:260 [inlined]
[4] buildings_from_file(file_path::String)
@ LightOSM ~/.julia/packages/LightOSM/Lf5Q0/src/buildings.jl:294
[5] top-level scope
@ REPL[21]:2
Any insights are appreciated!
julia> Pkg.status.(["LightOSM", "OSMMakie"])
Project OSM_test v0.1.0
Status `~/Documents/julia_playground/OSM_test/Project.toml`
[d1922b25] LightOSM v0.2.11
Project OSM_test v0.1.0
Status `~/Documents/julia_playground/OSM_test/Project.toml`
[76b6901f] OSMMakie v0.0.7
Could you please register the package? It takes several days from submission to registration. Moving to an org after a registration is not a problem.
Hi, it doesn't work yet, once again, here is the code I use to test:
using Agents
model, zombie_step!, model_step! = Models.zombies()
using OSMMakie
using GLMakie
ac(agent) = agent.infected ? :green : :black
as(agent) = agent.infected ? 6 : 5
fig = Figure(); display(fig)
ax = Axis(fig[1,1])
osmplot!(ax, model.space.map)
ids = model.scheduler(model)
colors = Observable([ac(model[i]) for i in ids])
sizes = Observable([as(model[i]) for i in ids])
pos = Observable(Point2f[OSM.latlon(model[i].pos, model) for i in ids])
scatter!(ax, pos; color = colors, markersize = sizes)
with Agents master. This code is useful because now the default graph is different. It already highlighted one problem.
In line 41 in recipe.jl you need to write zip(1:Graphs.ne(osm.graph),
instead of 1:osm.gra.ne
. Not all graphs have a .ne
field, but the ne
function always returns the number of edges. I was going to do a PR but even after this fix there is another problem:
ERROR: LoadError: KeyError: key :osm_edge_colors not found
Stacktrace:
[1] getindex(h::Dict{Symbol, Observable}, key::Symbol)
@ Base .\dict.jl:481
[2] getindex
@ C:\Users\datse\.julia\packages\MakieCore\S8PkO\src\attributes.jl:96 [inlined]
[3] getindex
@ C:\Users\datse\.julia\packages\MakieCore\S8PkO\src\attributes.jl:192 [inlined]
[4] getproperty
@ C:\Users\datse\.julia\packages\MakieCore\S8PkO\src\attributes.jl:83 [inlined]
[5] set_edge_defaults(osmplot::Combined{OSMMakie.osmplot, Tuple{LightOSM.OSMGraph{Int32, Int64, Float64}}})
@ OSMMakie C:\Users\datse\.julia\dev\OSMMakie\src\defaults.jl:45
[6] plot!(osmplot::Combined{OSMMakie.osmplot, Tuple{LightOSM.OSMGraph{Int32, Int64, Float64}}})
@ OSMMakie C:\Users\datse\.julia\dev\OSMMakie\src\recipe.jl:55
[7] plot!(scene::Scene, P::Type{Combined{OSMMakie.osmplot, Tuple{LightOSM.OSMGraph{Int32, Int64, Float64}}}}, attributes::Attributes, input::Tuple{Observable{LightOSM.OSMGraph{Int32, Int64, Float64}}}, args::Observable{Tuple{LightOSM.OSMGraph{Int32, Int64, Float64}}})
Indeed, looking at the definition of Attributes
at lline 23, there isn't any attribute with that name. I'm not sure how to fix this part as I've never learned the Makie recipe system yet.
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
Judging by JuliaDynamics/Agents.jl#620 we need a basic test suite for OSMMakie.
elabels_textsize
according to zoom level and/or edge lengthhide_elabels
and hide_nlabels
and dynamically change plotelabels
for duplicate ways (i.e. reduce label overlap)elabels
I get error:
ERROR: LoadError: Buffer position does not have the same length as the other buffers.
offset has length 2411
position has length 1483
scale has length 241
on running the script (requires Agents#master
):
using Agents
model, zombie_step!, model_step! = Models.zombies()
using OSMMakie
using GLMakie
ac(agent) = agent.infected ? :green : :black
as(agent) = agent.infected ? 6 : 5
fig, ax, plot = osmplot(model.space.map)
display(fig)
The only reason for me to use Agents
is to get the map of Geottingen. Since you have not encountered this issue so far, that's why I'm explicitly using Agents, so that we get the map that has the problem.
Don't know if its a problem with map or some assumption of hte plotting library.
cc @fbanning , @ AayushSabharwal
As described here we cannot use findmax
in the size_nodes
function. It is only available from Julia 1.7 onward.
This light yellow color is barely visible so I'd like to change it for InteractiveDynamics.jl. I am not sure how to do that though. I had a look at the source code, and I believe I need to provide something to graphplotkwargs
, but I am not sure what... What kind of street is the one that has this light yellow color...?
Just a typicallity:
┌ Warning: Package OSMMakie does not have InteractiveUtils in its dependencies:
│ - If you have OSMMakie checked out for development and have
│ added InteractiveUtils as a dependency but haven't updated your primary
│ environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with OSMMakie
└ Loading InteractiveUtils into OSMMakie from project dependency, future warnings for OSMMakie are suppressed.
WARNING: Method definition registration_setup!(Any, GraphMakie.GraphInteraction) in module GraphMakie at C:\Users\datse\.julia\packages\GraphMakie\tEQ8U\src\interaction.jl:45 overwritten in module OSMMakie at C:\Users\datse\.julia\dev\OSMMakie\src\interaction.jl:6.
** incremental compilation may be fatally broken for this module **
Standard library packages still need to be added to project.toml
Yeah, sorry I wasn't clear. It may be convenient to allow the user to pass a dictionary to
osmplot!
(or to propagate keyword arguments) so that the user can decide the color of the street types instead of the individual edges.
Originally posted by @Datseris in #8 (comment)
We have a pretty basic default theme in src/defaults
. In default_consts.jl
we for example define some dictionaries for colours, widths, and styles of edges depending on their way type ("motorway", "pedestrian", ...). These attributes are then used in defaults.jl
for construction of the related edge attributes.
It would be very nice to implement some kind of basic theming support for users to change the colourscheme, widths, etc.
There might be two possible ways to do this:
Makie.set_theme!
or Makie.with_theme
. This is a more fundamental change and will require some research into Makie themes. I'm not sure if it provides all the detailed layers of theming that we require.Currently all roads are comprised of multiple "unconnected" linesegments
which just happen to end at the same position at which another linesegment starts. This leads to precise display of street corners and such. But this precision doesn't look so nice when there are sharp bends in a road and leads to whitespace which reveals that the linesegments aren't connected to each other.
GraphMakie provides the ability to pass waypoints to plot an edge, see https://juliaplots.org/GraphMakie.jl/stable/generated/plots/#Edge-waypoints . Using this functionality with a small r
value could lead to nicer looking roads/edges with the underlying data on how their nodes are interconnected.
Current defaults look like this:
I think it would be nice to use a less harsh color for larger roads instead of this thick black. Some reds, oranges, and yellows will make a for a more pleasant map maybe?
e.g.,
(p.s.: it is not clear from the docs how to change these defaults via keywords to osmplot!
)
HM Revenue and Customs building has two holes in it
and it seems to render not correctly
https://github.com/fbanning/OSMMakie-assets/blob/master/London_buildings.png
At the moment streets are plotted with white triagnles that show direction:
However for large maps this is not a useful feature as it strongly decreases visibility, and the road widths remain the same under zoom meaning that even if I zoom in the plot I still can't really tell apart which direction the triangles point.
I'd like to disable the triangles. How can I do that? Can we add a simple keyword argument to the plot function?
Examples set aspect = DataAspect()
. The Gherkin building top rightish should be a circle, not an ellipse
https://github.com/fbanning/OSMMakie-assets/blob/master/London_buildings.png
A bit better would be autolimitaspect = 1/cosd(latitude)
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.