From 7465e005098a503daf8cf66dae63f560ae6c0c88 Mon Sep 17 00:00:00 2001 From: Timo Stomberg <t.stomberg@fz-juelich.de> Date: Fri, 6 Nov 2020 13:37:08 +0100 Subject: [PATCH] cartopy instead of basemaps --- source/dataset_mapplot.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/source/dataset_mapplot.py b/source/dataset_mapplot.py index 06ba28e..617e059 100644 --- a/source/dataset_mapplot.py +++ b/source/dataset_mapplot.py @@ -1,7 +1,7 @@ import numpy as np import pandas as pd import matplotlib.pyplot as plt -from mpl_toolkits.basemap import Basemap +import cartopy import random from settings import * @@ -35,25 +35,26 @@ class MapPlot: self.markers = [] def plot(self, annotate=False): - tmap = Basemap(projection='cyl', resolution='l') - tmap.drawcoastlines() - tmap.fillcontinents() - tmap.drawcountries() + ax = plt.axes(projection=cartopy.crs.PlateCarree()) + ax.add_feature(cartopy.feature.COASTLINE) + ax.add_feature(cartopy.feature.BORDERS, linestyle=':') + ax.add_feature(cartopy.feature.LAND) + ax.add_feature(cartopy.feature.OCEAN) for i in range(len(self.data_plot)): lons = self.data_plot[i]['lon'].to_list() lats = self.data_plot[i]['lat'].to_list() - x, y = tmap(lons, lats) + x, y = lons, lats - tmap.scatter(x, y, - s=50, - color=self.colors[i], - marker=self.markers[i], - alpha=0.5, - edgecolor='black', - label=self.labels[i], - zorder=2) + ax.scatter(x, y, + s=50, + color=self.colors[i], + marker=self.markers[i], + alpha=0.5, + edgecolor='black', + label=self.labels[i], + zorder=2) if annotate: if i == 0: -- GitLab