villares,
@villares@ciberlandia.pt avatar

Despite my recent absolute failure with , here we go again:

Dear toot-pals, where can I find wholesome learning materials on and/or / / in ?

I've been playing with via , which is awesome , but I struggle with simple stuff like adding a bunch of places as markers. Everything looks a bit like the owl drawing meme, either showing something too easy and useless, or something too advanced and also useless or beyond my comprehension. Maybe some other Python tools?
(I know about Marcelo's fabulous PrettyMaps but it is not exactly a viz tool)

ZorzalErrante,

@villares Hi, this is the repository I use to teach visualization and in my daily vis. work: https://github.com/zorzalerrante/aves Although it is mostly in Spanish and it is not easy to grasp, it has lots of maps using and . I hope it helps.

villares,
@villares@ciberlandia.pt avatar

@ZorzalErrante gracias!

geodesk,

@villares GeoDesk for Python (https://docs.geodesk.com/python) covers a lot of what you're looking for. You can easily query and analyze OpenStreetMap features and display them on a Leaflet map.

geodesk,

@villares - Example: To visualize all primary roads in São Paulo:

import geodesk

brazil = geodesk.Features("brazil.gol") # The file created by the GOL Tool
sao_paulo = brazil("a[boundary=administrative][admin_level=8][name='São Paulo']").one
roads = brazil("w[highway=primary]")
roads(sao_paulo).map.show()

villares,
@villares@ciberlandia.pt avatar

@geodesk thank you very much, looks wonderful!

I hope it won't be an abuse of your friendly helpfulness to ask some follow up questions:

1a. How would you geocode a list of 10 addresses to show on that map...
1b. If the former is cumbersome, it could be a list of lat-long coordinates of points of interest.

  1. How would you show a translucent circle showing a 100 meter radius around the points of interest.
geodesk,

@villares Happy to help!
For geocoding, you'd need something like Nominatim (https://nominatim.org/release-docs/latest/library/Getting-Started/) or @opencage (https://opencagedata.com/tutorials/geocode-in-python)

If you just need the city, you can do a contains query:
cities = brazil("a[boundary=administrative][admin_level=8]")
cities.contains(point)
print(f"Point is in {cities.first.name}")

To get the lon/lat of features:
for poi in features:
print(f"{poi.name}: {poi.lon}, {poi.lat}")

villares, (edited )
@villares@ciberlandia.pt avatar

@geodesk @opencage great, I've been using Nominatim via osmnx, I guess. I was wondering if you wrapped some other gecoding feature... I'll look at @opencage!!!

geodesk,

@villares To display a circle, you can use this:

from geodesk import *
import shapely

pt = shapely.Point(lonlat(-46.6, -23.5))
circle = shapely.buffer(pt, to_mercator(meters=100, lat=23))
m = Map()
m.add(circle, opacity=0.2)
m.show()

(Which remind me, we should implement an add_circle() method directly in Map) -- https://docs.geodesk.com/python/Map

If you need a shape that encompasses multiple POIs, you can also use Shapely to create a convex hull, and then buffer it. See https://shapely.readthedocs.io/en/stable/reference/shapely.convex_hull.html#shapely.convex_hull

villares,
@villares@ciberlandia.pt avatar

@geodesk very cool. I have used shapely before. The to_mercator() thing seems to take care of the projection and CRS issues I suppose!

geodesk,

@villares Yes, to_mercator() and from_mercator() are used to convert between latitude/longitude and Mercator units. Shapely simply assumes a Euclidean plane without any particular unit of measure. to_mercator(meters=100, lat=-23) gives you the number of Shapely units that equate to 100 meters at -23 degrees latitude (In the Mercator projection the scale depends on latitude -- there are more units per meter the closer you move towards the polar regions). https://docs.geodesk.com/python/mercator

villares, (edited )
@villares@ciberlandia.pt avatar

@geodesk yeah, I know Mercator, is leaflet always Mercator?

geodesk,

@villares In theory, Leaflet can work with other projections, but virtually all the base map tiles are in Web Mercator (EPSG:3857). GeoDesk uses a slightly modified projection based on EPSG:3857, here is more info: https://docs.geodesk.com/core-concepts#coordinate-system

villares,
@villares@ciberlandia.pt avatar

@geodesk ✨🙏👍

diesch,

@villares geodesk.com/ looks promising but I haven't used it yet. It uses leaflet to show maps.

slackline,
@slackline@mastodon.social avatar

@villares I've found Leaflet to be a really easy way to work with maps in Python.

The Python package to use for this is called Folium

A useful tutorial to get you started is

https://realpython.com/python-folium-web-maps-from-data/

rennerocha,
@rennerocha@chaos.social avatar

@villares I have used before and it is pretty easy to have a map running with custom markers. I didn't do anything big, but for smaller maps (maybe bigger ones too), it is a great suggestion from @slackline

  • All
  • Subscribed
  • Moderated
  • Favorites
  • maps
  • DreamBathrooms
  • everett
  • osvaldo12
  • magazineikmin
  • thenastyranch
  • rosin
  • normalnudes
  • Youngstown
  • Durango
  • slotface
  • ngwrru68w68
  • kavyap
  • mdbf
  • InstantRegret
  • JUstTest
  • ethstaker
  • GTA5RPClips
  • tacticalgear
  • Leos
  • anitta
  • modclub
  • khanakhh
  • cubers
  • cisconetworking
  • megavids
  • provamag3
  • tester
  • lostlight
  • All magazines