Add a Basemap
You can use the add_basemap
function to add a basemap to be
displayed as a background map.
The basemap provider is specified in the source
parameter which can be
either a xyzservices.TileProvider
object or an URL. If the
source
parameter is not defined, then it uses the default
basemap.
Oracle Spatial AI already provides basemaps based on eLocation. The following basemaps
are available through oraclesai.vis.elocation
:
osm_positron
(default)osm_bright
osm_darkmatter
world_map_mb
See the add_basemap function in Python API Reference for Oracle Spatial AI for more details.
The following code displays the geometries of the
block_groups
SpatialDataFrame
using two different basemaps.
import matplotlib.pyplot as plt
from oraclesai.vis import plot_geometries, add_basemap, elocation
fig, ax = plt.subplots(1, 2, figsize=(15,10))
# Set the titles
ax[0].set_title('Default Basemap');
ax[1].set_title('osm_darkmatter Basemap');
plot_geometries(data=block_groups, with_basemap=True, ax=ax[0], edgecolor='black', linewidth=0.2 )
plot_geometries(data=block_groups, ax=ax[1], edgecolor='black', linewidth=0.2 )
add_basemap(ax=ax[1], source=elocation.osm_darkmatter, crs=block_groups.crs)
By defining the with_basemap=True
parameter in the
plot_geometries
function, the default basemap is displayed (see the
left image in the following figure). A different basemap can be added with the
add_basemap
function.
Alternatively, you can set the with_basemap=elocation.osm_darkmatter
parameter in the plot_geometries
function (see the right image in the
following figure). In this case, you can omit calling the add_basemap
function.
The following figure shows the background basemap added by both the preceding methods.