matplotlib-basemap

Using pcolormesh for plotting an orbit data

大憨熊 提交于 2019-11-27 18:57:32
问题 I am trying to map a dataset with associated latitude and longitude. The details of the data I am using are given below: Variable Type Data/Info ------------------------------- lat ndarray 1826x960, type `float64` lon ndarray 1826x960, type `float64` data ndarray 1826x960, type `float64` I have created then a basemap: m = Basemap(projection='cyl', llcrnrlon=-180, urcrnrlon=180, llcrnrlat=-40, urcrnrlat=40, resolution='c') Now, on the basemap created, I'd plot the above mentioned dataset using

Basemap library using Anaconda Jupyter Notebooks - KeyError: PROJ_LIB

做~自己de王妃 提交于 2019-11-27 16:11:02
问题 I'm trying to install and import the Basemap library into my Jupyter Notebook, but this returns the following error: KeyError: 'PROJ_LIB' After some research online, I understand I'm to install Basemap on a separate environment in Anaconda. After creating a new environment and installing Basemap (as well as all other relevant libraries), I have activated the environment. But when importing Basemap I still receive the same KeyError. Here's what I did in my MacOS terminal: conda create --name

Is it possible to control matplotlib marker orientation?

六月ゝ 毕业季﹏ 提交于 2019-11-27 14:39:44
问题 I would like to know if I have a triangular marker, is it possible to control its orientation? I have a series of facets, with their corresponding vertices, and I would like to plot a basemap of them. I know it is straight forward script when using Mayavi and tvtk.PolyData. But since I'm dealing with maps and not 3D objects, things got a bit complicated. ps: for maps I'm using basemap tool. I thanks for any help. 回答1: You can create custom polygons using the keyword argument marker and

How to show shapefile label in python basemap legend?

坚强是说给别人听的谎言 提交于 2019-11-27 14:14:48
The python Basemap has two contents plotted in it: A multiline shapefile (IL_State_ln) and a scatterplot of some random points within the basemap extent. My interest is in generating a legend that gives information about both shapefile and the scatter points. For now, I am only able to include the points in the legend and not the shapefile. Checking the Basemap API documentation does not provide any information, as the function readshapefile() does not seem to have any label argument. Could you please help me include the shapefile indicator in the legend like in the ArcGIS maps? Here is my

Draw polygons more efficiently with matplotlib

隐身守侯 提交于 2019-11-27 11:15:36
问题 I have a dateset of around 60000 shapes (with lat/lon coordinates of each corner) which I want to draw on a map using matplotlib and basemap. This is the way I am doing it at the moment: for ii in range(len(data)): lons = np.array([data['lon1'][ii],data['lon3'][ii],data['lon4'][ii],data['lon2'][ii]],'f2') lats = np.array([data['lat1'][ii],data['lat3'][ii],data['lat4'][ii],data['lat2'][ii]],'f2') x,y = m(lons,lats) poly = Polygon(zip(x,y),facecolor=colorval[ii],edgecolor='none') plt.gca().add

Plot GDAL raster using matplotlib Basemap

青春壹個敷衍的年華 提交于 2019-11-27 10:37:39
问题 I would like to plot a raster tiff (download-723Kb) using matplotlib Basemap. My raster's projection coordinates is in meter: In [2]: path = r'albers_5km.tif' raster = gdal.Open(path, gdal.GA_ReadOnly) array = raster.GetRasterBand(20).ReadAsArray() print ('Raster Projection:\n', raster.GetProjection()) print ('Raster GeoTransform:\n', raster.GetGeoTransform()) Out [2]: Raster Projection: PROJCS["unnamed",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG"

Python Matplotlib Basemap overlay small image on map plot

半世苍凉 提交于 2019-11-27 05:34:25
问题 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. 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

Basemap import error in PyCharm — KeyError: 'PROJ_LIB'

你离开我真会死。 提交于 2019-11-27 01:37:03
问题 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

Python basemap module impossible to import

…衆ロ難τιáo~ 提交于 2019-11-26 22:57:26
问题 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"

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

空扰寡人 提交于 2019-11-26 22:09: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