matplotlib-basemap

Keep transparency with basemap warpimage

断了今生、忘了曾经 提交于 2019-12-10 18:25:33
问题 I have an RGBA png map with all oceans transparent. I want to use Basemap in a north pole stereographic projection and this map with warpimage. The transparency is lost and replaced by black when I want to keep it. What can i do ? My final goal is to plot a color grid in oceans and then the transparent map above it. from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt m = Basemap(projection='npstere',boundinglat=60,lon_0=300,resolution='l',round=True) m.drawlsmask(ocean

how to display a image over a map with imshow?

泪湿孤枕 提交于 2019-12-10 17:38:40
问题 I have a geotif with 9 different colour values (0-9) and want to display it over a map. I'm trying to use it with basemap from the matplotlib package. from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt im = plt.imread('a.tif') extent = [-18, 52, -38, 38] # [left, right, bottom, top] m = Basemap(projection='merc', llcrnrlon=extent[0], urcrnrlon=extent[1], llcrnrlat=extent[2], urcrnrlat=extent[3], resolution='c') m.drawcountries() plt.imshow(im, extent=extent, alpha=0.6)

Testing point with in/out of a vector shapefile

核能气质少年 提交于 2019-12-10 16:05:16
问题 Here is my question. 1. Intro a shapefile in polygon type represent the study area http://i8.tietuku.com/08fdccbb7e11c0a9.png some point located in the whole rectangle map http://i8.tietuku.com/877f87022bf817b8.png I want to test whether each point was located within/out the polygon and do some further operation(for example, sum the grid point amount within the study area) 2. My idea I have two methods all thanks to the information on stack overflow. 2.1 Idea A Rasterize the shapefile into

ImportError when importing Basemap

馋奶兔 提交于 2019-12-10 15:43:34
问题 I have problems importing basemap, even though I just installed it via pip install basemap . I've tried both with python2.7 and python3: python3 >>> from mpl_toolkits.basemap import Basemap Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'mpl_toolkits' python2.7 >>> from mpl_toolkits.basemap import Basemap Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/site-packages/mpl_toolkits/basemap/

Matplotlib Subplot Animation with Basemap

元气小坏坏 提交于 2019-12-10 15:43:11
问题 I am trying to generate a four-panel animation of temperature change with time. Each of the four panels in the subplot should be an animated map; the difference between each panel being the data used. I have managed to generate the animation using one set of data (without subplots) with the following code: import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation from mpl_toolkits.basemap import Basemap #dummy temperature data with 10 time-steps y=np.random

Python Basemap “Assertion failed”

旧巷老猫 提交于 2019-12-10 14:55:52
问题 I am using Anaconda 2.1.0 and Basemap installation is successful conda install basemap conda install gdal I have geos version 3.3.3 and proj4 4.8.0-0. However, I keep getting the following error when I try to project (lat,lon) degrees to a planar: Assertion failed: (0), function query, file AbstractSTRtree.cpp, line 286. My code looks like this: import shapely.geometry as sg from pymongo import MongoClient from mpl_toolkits.basemap import Basemap p = Basemap(projection='sinu',lon_0=0

Changing Basemap projection causes data to disappear

╄→尐↘猪︶ㄣ 提交于 2019-12-10 11:48:02
问题 Exactly as the title says. I'm plotting sea ice concentration data and this code: map = Basemap(projection='cyl', lat_0 = lat_0, lon_0 = lon_0, llcrnrlon = llcrnrlon, llcrnrlat = llcrnrlat, urcrnrlat = urcrnrlat, urcrnrlon = urcrnrlon, area_thresh = 1000., resolution='l') Works just fine. http://i.imgur.com/8i36gn0.png But when I try to change the projection: map = Basemap(projection='npstere',boundinglat=10,lon_0=270,resolution='l') I just get a blank map. http://i.imgur.com/5TazZdC.png Am I

3D CartoPy similar to Matplotlib-Basemap

前提是你 提交于 2019-12-08 23:36:01
问题 I'm new to Python with a question about Cartopy being able to be used in a 3D plot. Below is an example using matplotlibBasemap . import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.basemap import Basemap m = Basemap(projection='merc', llcrnrlat=52.0,urcrnrlat=58.0, llcrnrlon=19.0,urcrnrlon=40.0, rsphere=6371200.,resolution='h',area_thresh=10) fig = plt.figure() ax = Axes3D(fig) ax.add_collection3d(m.drawcoastlines(linewidth=0.25)) ax.add_collection3d(m

How to plot a shapefile centered in the Pacific with Basemap?

谁都会走 提交于 2019-12-08 09:38:38
问题 When plotting with Basemap's readshapefile , if the defined map is centered anywhere else than the longitudinal center of the shapefile, only a portion of it it's plotted. Here's an example using Natural Earth's coastlines: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap shpf = './NaturalEarth/ne_50m_land/ne_50m_land' fig, ax = plt.subplots(nrows=1, ncols=1, dpi=100) m = Basemap( ax = ax, projection = 'cyl', llcrnrlon = 0, llcrnrlat = -90, urcrnrlon

Trouble in installing Basemap in matplotlib

…衆ロ難τιáo~ 提交于 2019-12-08 08:35:06
问题 I am trying to install Basemap, and beforehand I already have the prerequisite versions of Matplotlib, Python and Numpy working on my Mac. To install Basemap I am following the instructions in this website http://matplotlib.org/basemap/users/installing.html I seemed to progress quite well with the steps, until the very end which is "Check your installation by running from mpl_toolkits.basemap import Basemap at the python prompt." I got "ImportError: cannot import name pyproj" from a line that