I just want to use Planet tiles as a basemap for a Jupyter Notebook application, using ipyleaflet widget.

In my environment, I imported these packages:

from ipyleaflet import Map, basemaps, basemap_to_tiles, TileLayer

Now, I am trying to initialize a map and streaming Planet tiles using my API.

planet_tiles_url=("https://tiles{0}.planet.com/basemaps/v1/planet-tiles/global_monthly_2016_05_mosaic/gmap/{x}/{y}/{z}.png?api_key=abc123")
tile_layer=TileLayer(url=planet_tiles_url)

m = Map(
    default_tiles=tile_layer,
    center=center,
    zoom=14,
    scroll_wheel_zoom=True)

m.add_layer(tile_layer)
m.add_control(LayersControl())
m

No error pops up. But no Planet basemap is displayed and not even the layer controls. See image..

enter image description here

What am I doing wrong?

One thing that looks wrong is tiles{0}. Try just tiles. If that works, then try tiles{s} for a small performance improvement.

The other issue is the order of x, y and z in the tile URL. It should be {z}/{x}/{y}.

Here is working code:

from ipyleaflet import Map, TileLayer
planet_tiles_url=("https://tiles.planet.com/basemaps/v1/planet-tiles/global_monthly_2018_10_mosaic/gmap/{z}/{x}/{y}.png?api_key=API_KEY")
tile_layer=TileLayer(url=planet_tiles_url)

m = Map(
    default_tiles=tile_layer,
    zoom=4,
    scroll_wheel_zoom=True)

m.add_layer(tile_layer)
m

enter image description here

  • It did not work, but now I have another problem, the map doesn't show up. Not even the OpenStreetMap tiles which are default in ipywidget. I fix that, and let you updated. – Nick Pucino Nov 19 at 21:59
  • What version of ipyleaflet? – bosth Nov 19 at 22:14
  • I have ipyleaflet 0.9.1 – Nick Pucino Nov 19 at 22:21
  • Thx for providing a working example. As soon as I understand why no map appears in my NB, I will let you know if this works for me. – Nick Pucino Nov 19 at 23:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.