I want to project a map with its starting position like this
The current output that I get is like this
import holoviews as hv
from geoviews.tile_sources import EsriImagery
from holoviews.operation.datashader import datashade, dynspread
import datashader as ds
import colorcet as cc
hv.extension('bokeh', 'matplotlib')
c = df.loc[(df['dropoff_latitude'] >= 40.5) &
(df['dropoff_latitude'] <= 41) &
(df['dropoff_longitude'] >= -74.1) &
(df['dropoff_longitude'] <= -73.7)]
map_tiles = EsriImagery().opts(alpha=0.5, width=900, height=480, bgcolor='black')
points = hv.Points(ds.utils.lnglat_to_meters(c['dropoff_longitude'], c['dropoff_latitude']))
taxi_trips = datashade(points, dynamic = True, x_sampling=0.1, y_sampling=0.1, cmap=cc.fire, height=1000, width=1000)
map_tiles * taxi_trips
I tried to set a zoom_level or xrange, yrange in EsriImagery opts, but there are no such parameters. The method itself also has no documentation. And I couldn't find the documentation regrading this online too. (I could be looking at the wrong place.)
There are two ways to do this:
Option 1 -- dircet input
Set your wanted values using the parameter
x_range
andy_range
indatashade(...)
.Option 2 -- indirect input
If you don't know the needed values and you want to play around a bit, you can use this workaround.
The existing figure object has a
Range1d
object, and this has astart
andend
point. This can be printed and set by a user.This code starts with the last line of your example.
Here you have to get the bokeh (underlying package) figure and set your values. This values looks a bit odd and you maybe have to play a bit with it.
Output for both options
Here is the changed output.
I hope this works for you. Good luke.