Recommended python module for generating interactive / javascript plots?

Hi folks, I’m looking for recommendations for favorite python modules for generating interactive / javascript (i.e. leaflet.js) plots. Looking for ability to easily add both vector and raster layers. Need a workflow that is compatible with remote/cloud-based objects (i.e. gdal virtual filesystem) and ideally a able to automatically handle things like choosing an appropriate downsampling strategy for large images (rather than try and plot more pixels than the screen renders and crashing out of RAM :slight_smile: ). Other nice aspects would be an interface that toggle between static image plots and dynamic leaflet maps and can easily abstract ‘theme’-ing elements (color-schemes etc) from plotting code. It’s also nice if the library handles things like re-projecting or cropping additional layers to the CRS and bbox of the first layer but obviously that can be done manually.

For reference, I’m coming from R where tmap is commonly used for these things. (https://cran.r-project.org/web/packages/tmap/vignettes/tmap-getstarted.html)

Thanks!

1 Like

Have a look at Leafmap, which supports several data sources (local and remote) and map rendering libraries (including leaflet).

1 Like

Thanks @tylere , I’m really enjoying leafmap now. The demo is great and it’s impressive how simple the interface is.

Still I’m a bit confused how to convince it to use network range requests instead of downloading large file in their entirety, as it does a good job hiding what’s under the hood. For instance, in the example below, leafmap seems to download the entire shapefile first. Manually adding the gdal virtual filesystem prefixes just confuses it, so I gather it’s not using GDAL(?)

import leafmap
m = leafmap.Map()
mangroves_2015 = "https://datadownload-production.s3.amazonaws.com/GMW_v3_2015.zip"
#mangroves_2015 = "/vsizip/vsicurl/https://datadownload-production.s3.amazonaws.com/GMW_v3_2015.zip" # file not found

m.add_shp(mangroves_2015, layer_name="Mangroves 2015")

Is there an alternative/better strategy here? (note this is a large-ish shapefile in this example)