I am plotting the drift track of multiple buoys in the arctic. I need a map in the polar stereographic projection and then to plot many latitude/longitude pairs from a dataframe on the the map. What packages work with this. I thought that Folium looked really nice, but I don't think that it can do different projections. There is also basemap, cartopy...
Any thoughts?
Cartopy supports a north polar stereographic projection and can be used with matplotlib to create a map and plot datapoints. The Cartopy documentation includes examples of how to plot points on a map projection.
GeoViews supports NorthPolarStereo projection. GeoViews using a Bokeh extension support map interactivity like panning and zoom similar to Folium.
Related
I am making maps of meteorological data (x,y-coordinates in m) using matplotlib.pyplot.contourf(). I want to plot a coastline, but all the examples I find on internet use lat-lon data (with cartopy or basemap).
Is there a way (without transforming the data to a lat-lon grid) to plot a coastline on my cartesian grid? I know size of the grid, and its center's lat-lon coordinates.
I haven't tried anything but look for similar examples, which I could not find.
The solution is to use cartopy's gnomonic projection: https://scitools.org.uk/cartopy/docs/v0.15/crs/projections.html#gnomonic , e.g.
proj =ccrs.Gnomonic(central_latitude=0, central_longitude= 0)
The origin of the data need to be specified (in lat-lon), and it expects the data coordinates to be distance in meters from that origin. Then, the normal cartopy features (like coastlines) work as usual.
I have a xarray dataset clip_ds and have visualised the data array using plot. Now, I want to add a country boundary using Basemap's drawcountries(). Apparently, there is something wrong with the extent I am using in basemap (I guess), but both the country border and the data plot won't show up together. I have tried interchanging the position of clip_ds.pr[0].plot() before and after I create basemap, and it gives me two different results as shown below:
Xarray PLOT BEFORE BASEMAP (Note that the colorbar from xarray plot is still there)
Xarray PLOT AFTER BASEMAP (Notice difference from 3, height of the plot shrinks here and the tick labels disappears, probably overlapped by basemap.)
Xarray plot only
Loading seperate shapefile using map.readshapefile also gives same kind of problem. I know there might be a way around this using cartopy, but I like the Basemap functionalities and would like to know if there is any solution to this.
map=Basemap(projection='merc',
resolution='l',
llcrnrlon=clip_ds.lon[0],
llcrnrlat=clip_ds.lat[0],
urcrnrlon=clip_ds.lon[-1],
urcrnrlat=clip_ds.lat[-1])
map.drawcountries()
clip_ds.pr[0].plot()
plt.show()
I was wondering if there is a way to draw contour plots in altair.
Matplotlib has api for contour plots as demonstrated here
There isn't a dedicated api for contour in Altair documentation
but i guess may be we could use the grammar to create one ?
Altair does not support contour plots, because they are not supported in Vega-Lite. The issue that tracks contour support in Vega-Lite can be found here: https://github.com/vega/vega-lite/issues/1919
I had developed scatter and lasso selection plots with Chaco. Now, I need to embed a BaseMap [with few markers on a map] onto the plot area side by side.
I created a BaseMap and tried to add to the traits_view; but it is failing with errors.
Please give me some pointers to achieve the same.
Chaco and matplotlib are completely different tools. Basemap has been built on top of matplotlib so it is not possible to add a Basemap map on a Chaco plot.
I'm afraid I couldn't find any mapping layer to go with Chaco. Is there a reason you cannot use matplotlib for you plot?
I would like to plot multiple pie charts over an existing plot using absolute coordinates.
I went through the add_axes method and also the AxesGrid toolikt but couldn't find a solution.
To be more specific, I want to draw pie charts over a geographical map using the basemap module.
This tutorial explains how to use matplotlib Basemap for drawing pie charts on a map. It is fairly simple and gives code examples.