I installed the Python Cartopy mapping tool on a Mac running El Capitan 10.11.6 with Python 3.4. I can use Cartopy to successfully build some maps, but in some cases the Python core dies with a segmentation error of 11.
I need an installation that I could easily remove from my computer if the need arises. So I installed Python 3.4 and the necessary dependencies using fink:
$ fink install python34
$ fink install gdal2
$ fink install gdal2-dev
$ fink install proj
$ fink install libproj9
Then I created a virtual environment using pyvenv (but also tried virtualenv and venv) and activated it.
In an activated virtual environment, I used pip to install:
$ pip install cython
$ pip install numpy
$ pip install shapely
$ pip install pyshp
$ pip install pandas
$ pip install matplotlib
$ pip install pillow
$ pip install pyepsg
$ pip install scipy
$ pip install OWSLib
$ pip install mock
$ pip install nose
$ pip install pep8
$ pip install jupyter
, , Cartopy, : http://scitools.org.uk/cartopy/docs/v0.15/installing.html
Cartopy, ( ) geos, fink:
pip install --global-option=build_ext --global-option="-I/sw/opt/libgeos3.5.0/include" --global-option="-L/sw/opt/libgeos3.5.0/lib" cartopy
Python Jupyter, , Cartopy . - Cartopy, .
:
import matplotlib
matplotlib.use("TkAgg")
cartopy.crs as ccrs
import matplotlib.pyplot as plt
ax = plt.axes(projection=ccrs.Mollweide())
ax.stock_img()
plt.show()
:
import os
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
from cartopy import config
import cartopy.crs as ccrs
fig = plt.figure(figsize=(8, 12))
fname = os.path.join(config["repo_data_dir"],
'raster', 'sample', 'Miriam.A2012270.2050.2km.jpg'
)
img_extent = (-120.67660000000001, -106.32104523100001, 13.2301484511245, 30.766899999999502)
img = plt.imread(fname)
ax = plt.axes(projection=ccrs.PlateCarree())
plt.title('Hurricane Miriam from the Aqua/MODIS satellite\n'
'2012 09/26/2012 20:50 UTC')
ax.set_xmargin(0.05)
ax.set_ymargin(0.10)
ax.imshow(img, origin='upper', extent=img_extent, transform=ccrs.PlateCarree())
ax.coastlines(resolution='50m', color='black', linewidth=1)
ax.plot(-117.1625, 32.715, 'bo', markersize=7, transform=ccrs.Geodetic())
ax.text(-117, 33, 'San Diego', transform=ccrs.Geodetic())
plt.show()
:
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
import cartopy
ax = plt.axes(projection=cartopy.crs.PlateCarree())
ax.add_feature(cartopy.feature.LAND)
ax.add_feature(cartopy.feature.OCEAN)
ax.add_feature(cartopy.feature.COASTLINE)
ax.add_feature(cartopy.feature.BORDERS, linestyle=':')
ax.add_feature(cartopy.feature.LAKES, alpha=0.5)
ax.add_feature(cartopy.feature.RIVERS)
ax.set_extent([-20, 60, -40, 40])
plt.show()
, , .
, :
Segmentation fault: 11
- ?