Posted in Packages

Cartopy

Cartopy is a Python package designed to make drawing maps for data analysis and visualisation as easy as possible. Some of the key features of cartopy are: object oriented projection definitions; point, line, vector, polygon and image transformations between projections; integration to expose advanced mapping in matplotlib with a simple and intuitive interface; powerful vector data handling by integrating shapefile reading with Shapely capabilities

http://scitools.org.uk/cartopy/

Status: Actively developed

Depends on: Cython, Numpy, GEOS C++, Shapely, PyShp, Proj4 C++, six

Optional extensions: Matplotlib, GDAL, PIL, pyepsg, SciPy, OWSLib

Python versions: 2.7, 3

 

Examples:

Embedding in a Tkinter GUI


# Source: http://stackoverflow.com/questions/20385453/how-to-embed-cartopy-in-a-python-tkinter-gui

from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure

import cartopy.crs as ccrs

import sys
import Tkinter as Tk

root = Tk.Tk()
root.wm_title("Cartopy in TK")

fig = Figure(figsize=(8,4), dpi=100)

ax = fig.add_axes([0.01, 0.01, 0.98, 0.98],
projection=ccrs.InterruptedGoodeHomolosine())
ax.set_global()
ax.stock_img()
ax.coastlines()

ax.set_title('Cartopy and Tkinter')

# a tk.DrawingArea
canvas = FigureCanvasTkAgg(fig, master=root)
canvas.show()
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

button = Tk.Button(master=root, text='Quit', command=sys.exit)
button.pack(side=Tk.BOTTOM)

Tk.mainloop()

 

Installation:

Windows binary

http://www.lfd.uci.edu/~gohlke/pythonlibs/#cartopy

Compiling from source

http://scitools.org.uk/cartopy/docs/latest/installing.html#building-from-source

Advertisements

Author:

Primarily I am a social scientist and data wrangler on topics of political violence and public opinion, but I have increasingly gotten into Python programming and development, particularly focusing on geographic analysis, image rendering/drawing/visualization, and user-friendly Tkinter GUI software building.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s