matplotlib-basemap

Basemap import error in PyCharm — KeyError: 'PROJ_LIB'

自作多情 提交于 2019-11-28 08:25:35
I tried to use Basemap package to plot a map by PyCharm, but I got something wrong with from mpl_toolkits.basemap import Basemap` And the Traceback as followed: Traceback (most recent call last): File "/Users/yupeipei/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2963, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-4-0a24a3a77efd>", line 7, in <module> from mpl_toolkits.basemap import Basemap File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 20, in do_import module = self._system

Python basemap module impossible to import

冷暖自知 提交于 2019-11-28 08:18:22
I have troubles to import the basemap module of mpl_toolkits in python. Here is what I get when I run the test.py script from the module directory: /usr/lib/python2.7/dist-packages/mpl_toolkits/basemap$ python test.py Traceback (most recent call last): File "test.py", line 1, in <module> from mpl_toolkits.basemap import Basemap, shiftgrid ImportError: No module named basemap I can't get it since sys.path gives a list of paths where I am sure the directory "basemap" is, in the "mpl_toolkits" directory. There is no problem to import mpl_toolkits . Here is a thing I tried, to manually add the

Python Matplotlib Basemap overlay small image on map plot

你说的曾经没有我的故事 提交于 2019-11-28 05:20:48
I am plotting data from an aircraft on a map and I would like to insert this 75px by 29px PNG image of an airplane at the coordinates of the latest data point on the plot. airplane http://i45.tinypic.com/mslr86.jpg As far as I know and have read, pyplot.imshow() is the best way to accomplish this. However, I am getting hung up on step 1, getting the image to even display. Using a normal plot instead of Basemap, it is easy enough to get the image to appear using imshow, but when using Basemap, I can't get it to show up at all. See the example code. If I can get the image to display on the map,

OSError geos_c could not be found when Installing Shapely

こ雲淡風輕ζ 提交于 2019-11-28 02:37:59
问题 I'm a newbie to making/plotting on maps with python, been trying to follow this blogpost to generate a world map (http://sciblogs.co.nz/seeing-data/2011/08/12/plotting-geographic-data-on-a-world-map-with-python/). Got stuck with a few things here: Installing Basemap (a Matplotlib extension for plotting data on geographic projections). from mpl_toolkits.basemap import Basemap Traceback (most recent call last): File "geos_demo.py", line 1, in <module> from mpl_toolkits.basemap import Basemap

Plotting shapefile using LineCollection shows all edges, but partially fills them

十年热恋 提交于 2019-11-28 02:10:37
For the past few days I have been trying to get weather station data interpolated in a map for my country only. I do this as follows: Loading the data, I create a grid using interpolation Based on this grid I draw a contour and contourf image I then draw shapefiles for Germany, Belgium and France on top of the map in order to cover the irrelevant contour / contourf elements. I used this tutorial for that. Finally, I use an oceans shapefile (IHO Sea Areas; www.marineregions.org/downloads.php#iho) to plot as well in order to cover the North Sea. Using QGIS, I edited this oceans shapefile and

How to remove/omit smaller contour lines using matplotlib

岁酱吖の 提交于 2019-11-28 00:15:16
I am trying to plot contour lines of pressure level. I am using a netCDF file which contain the higher resolution data (ranges from 3 km to 27 km). Due to higher resolution data set, I get lot of pressure values which are not required to be plotted (rather I don't mind omitting certain contour line of insignificant values). I have written some plotting script based on the examples given in this link http://matplotlib.org/basemap/users/examples.html . After plotting the image looks like this From the image I have encircled the contours which are small and not required to be plotted. Also, I

why does my colorbar have lines in it?

怎甘沉沦 提交于 2019-11-27 19:59:09
Edit : Since this seems to be a popular post, here's the solution that seems to be working well for me. Thanks @gazzar and @mfra. cbar.solids.set_rasterized(True) cbar.solids.set_edgecolor("face") Does anyone know why my colorbar has what appear to be lines in it? Or rather why is the color transition not smooth? I'm using basemap, obviously, but that shouldn't matter since it's all matplotlib calls under the hood AFAICT. I create the map doing something like grays = plt.cm.get_cmap("Grays") sc = mymap.scatter(xpoints, ypoints, s=sizes, c=color_values, cmap=grays, alpha=.75, marker="o", zorder

Drawing a graph with NetworkX on a Basemap

笑着哭i 提交于 2019-11-27 19:58:09
问题 I want to plot a graph on a map where the nodes would be defined by coordinates (lat, long) and have some value associated. I have been able to plot points as a scatterplot on a basemap but can't seem to find how to plot a graph on the map. Thanks. EDIT : I have added code on how I plotted the points on a basemap. Most of it has been adapted from code in this article. from mpl_toolkits.basemap import Basemap from shapely.geometry import Point, MultiPoint import pandas as pd import matplotlib

Matplotlib: draw a selection area in the shape of a rectangle with the mouse

和自甴很熟 提交于 2019-11-27 19:55:23
I want to be able to draw a selection area on a matplotlib plot with a mouse event. I didn't find information on how to do it with python. In the end, I want to be able to draw a region of interest with my mouse on a map created with matplotlib basemap and retrieve the corner coordinates. Anyone has an idea, example, references? Thanks, Greg class Annotate(object): def __init__(self): self.ax = plt.gca() self.rect = Rectangle((0,0), 1, 1, facecolor='None', edgecolor='green') self.x0 = None self.y0 = None self.x1 = None self.y1 = None self.ax.add_patch(self.rect) self.ax.figure.canvas.mpl

IndexError with Basemap.contour() when using certain projections

烈酒焚心 提交于 2019-11-27 19:38:15
问题 I have run into problems when using Basemap.contour with certain projections. Based on the example given in the Basemap documentation, I created the following working code which produces the expected result. The example uses the 'tmerc' projection. from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np m2 = Basemap(projection='tmerc', lat_0=0, lon_0=3, llcrnrlon=1.819757266426611, llcrnrlat=41.583851612359275, urcrnrlon=1.841589961763497, urcrnrlat=41