How to specify map extent in GeoViews with map tiles in the background

60 Views Asked by At

If I have a GeoDataFrame of point geometries, I can plot it up with GeoViews and specify the longitude extent of the display like this:

import geopandas as gpd
import geoviews as gv
import numpy as np
gv.extension('bokeh')

gdf = gpd.GeoDataFrame(geometry = gpd.points_from_xy(np.linspace(-88, -82, 100), np.linspace(32,38, 100)), crs = 'WGS84')

points = gv.Points(data=gdf)
points = points.opts(xlim = (-86, -84))
points

enter image description here

However, if I try to add some background map tiles using gv.tile_sources, the exent gets messed up:

points_map = (gv.tile_sources.OSM*points)
points_map = points_map.opts(xlim = (-86, -84))
points_map

enter image description here

I think it probably has something to do with projections...the incorrect map above is centered around 0 degrees Longitude, so I think the map extent is being set to -86 to -84 meters or something like that. But I can't quite figure out how to properly set the extent.

How can I plot a gv.Points() display with a mapped tile underneath, and set the exent of the map display using decimal degree coordinates?

0

There are 0 best solutions below