I have been using geopandas, but I am trying to switch to geoviews because it is more interactive. I'm wondering how to specify the axis limits for plotted data as a default view. I understand that it will always plot all of the data that exist, but it would be nice to have a given zoom for the purpose of this project. I posted the image of the map output below. However, I want it to output with xlim = ([-127, -102]) and ylim = ([25, 44]). I looked on stackoverflow and other places online and was unable to find the answer.
# Read in shapefiles
fire = pd.read_pickle(r'fire_Aug2020.pkl')
fire = fire.loc[fire['FRP'] != -999.0, :]
# Assign gv.Image
data = gv.Dataset(fire[['Lon','Lat','YearDay']])
points = data.to(gv.Points, ['Lon','Lat'])
m = (points).opts(tools = ['hover'], width = 400, height = 200)
m
Your are very close to a working solution. Try to add xlim
and ylim
as tuple to the opts
call.
Minimal Example
Comment: GeoViews is based on Holoviews, see the documentation for more details.
Because GeoViews is not installed on my machine, the example below uses HoloViews. I will update this answer soon.
import pandas as pd
import numpy as np
import numpy as np
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')
fire = pd.DataFrame({'Lat':np.random.randint(10,80,50),'Lon':np.random.randint(-160,-60,50)})
data = hv.Dataset(fire[['Lon','Lat']])
points = data.to(hv.Points, ['Lon','Lat'])
(points).opts(tools = ['hover'], width = 400)
Above is the output without limits and below I make use of xlim
and ylim
.
(points).opts(tools = ['hover'], width = 400, height = 200, xlim=(-127,-102), ylim=(25,44))