oraclesai.vis

Functions for plotting spatial information and basemaps definitions.

Basemaps

elocation: Contains basemaps definitions which can be used as the value of with_basemap parameter, received by the plotting functions. The following basemaps are available:

  • osm_positron

  • osm_bright

  • osm_darkmatter

  • world_map_mb

add_basemap(ax, source=None, crs=None, **contextily_extra_kwargs)

Add the basemap specified by source to the given ax. If no source is provided, DEFAULT_BASEMAP is used.

Parameters:
  • ax – Matplotlib axes object on which to add the basemap

  • source – The basemap as an xyzservices.TileProvider object or URL. Available eLocation basemaps can be selected from elocation.

  • crs – Coordinate reference system (CRS), expressed in any format permitted by pyproj.

  • **contextily_extra_kwargs

    Parameters accepted by contextily.add_basemap()

plot_clusters(X, labels_, background_data=None, title=None, with_bounds=False, with_noise: bool | Dict = False, ax=None, cmap='prism', with_legend=True, with_basemap=False, crs=None, alpha=0.5)

Plot clustering result using matplotlib.

Parameters:
  • X – (SpatialDataFrame or geopandas.GeoDataFrame) The geometries to be plotted.

  • labels – Cluster labels to be associated to X.

  • background_data – (SpatialDataFrame or geopandas.GeoDataFrame) A spatial dataset used as background.

  • title – Title of the plot.

  • with_bounds – If True, the clusters will be drawn as a polygon.

  • with_noise – bool or dictionary. If True or a dictionary is passed, and the clustering algorithm categorizes some samples as noise (value -1), it will plot the noise samples. A dictionary can be passed with the followin properties: color, alpha.

  • ax – axes on which to draw the plot.

  • cmap – Color map from matplotlib.

  • with_legend – If True, the legend with the clusters labels will be added to the plot.

  • with_basemap – (boolean, xyzservices.TileProvider or dictionary). Specifies if a basemap should be added. If True, the default basemap will be used. If a TileProvider instance is passed (e.g., elocation.osm_bright), it will be used as basemap. Alternativelly, a dictionary can be passed with the parameters to oraclesai.vis.add_basemap(), except ax.

  • crs – (pyproj.CRS, or string) Coordinate Reference System of the geometry objects to be plotted. By default the X.crs is used.

  • alpha – Alpha used for X’s geometries.

plot_geometries(data, ax=None, with_basemap=False, **plot_extra_kwargs)

Plot data using matplotlib.

Parameters:
  • data – a SpatialDataFrame, A list of shapely geometries, a geopandas.GeoSeries or, geopandas.GeoDataFrame.

  • ax – axes on which to draw the plot.

  • with_basemap – (boolean, xyzservices.TileProvider or dictionary). Specifies whether a basemap should be added. If True, the default basemap will be used. If a TileProvider instance is passed (e.g., elocation.osm_bright), it will be used as basemap. Alternatively, a dictionary can be passed with the parameters to oraclesai.vis.add_basemap(), except ax.

  • **plot_extra_kwargs

    Parameters accepted by geopandas.GeoDataFrame.plot() (when data is a DataFrame) or geopandas.GeoSeries.plot() (when data is not a DataFrame).