introvert.net

about | chicago | history | links | logic | ontology | potentiality | rhetoric |

simple plotting of shapefiles using matplotlib

Tue 14 April 2015 — filed under rhetoric

Another gist that'll do simple GIS things for you in relatively simple python:

gist.github.com/tewhalen/wktplotpoly.py

This will let you plot shapefiles that contain POLYGONs and MULTIPOLYGONs (say, boundary files you get from the City of Chicago Data Portal) using matplotlib, and do some fun graphic things like:

% of housing that's SFH

With code that's as simple as:

:::python
from wktplotpoly import getPolygons

import matplotlib.cm as cm
import numpy.random as npr

# this setup code is probably necessary for reasonable use
fig = plt.figure(facecolor="white")
ax= plt.axes()

# pick random values for each CA
values = npr.rand(700)

# 1. install GDAL
# 2. download a shapefile
# 3. convert shapefile to CSV+WKT
#    ogr2ogr -f CSV output.csv input.shp -lco GEOMETRY=AS_WKT


coll = getPolygons("output.csv", key='TRACTCE10')

# color the polys using the random values
coll.set_cmap(cm.Reds)
coll.set_array(np.array(values))
coll.set_alpha(0.6) # for pretty

ax.add_collection(coll)
plt.axis('equal')
plt.axis('off')
plt.show()

making chicago community area cartograms

Fri 27 March 2015 — filed under rhetoric

I wrote some code that will turn datasets for the 77 community areas of Chicago into simple cartograms, allowing quick-and-dirty visualizations. It's for Python, using matplotlib.

gist.github.com/tewhalen

It can produce output like this, which shows the percentage of people 20-29 in each neighborhood, with each box ...

Read More

always read the study

Mon 09 February 2015 — filed under rhetoric

At The Public Discourse (before launching into a pretty tendentious Natural Law “explanation” of transgender) Carlos D. Flores writes:

Those in favor of transgenderism also (naturally) support gender-reassignment surgery as a perfectly legitimate medical procedure for individuals (including children) with gender dysphoria. Now, put to one side the fact that ...

Read More

containing multitudes

Fri 01 March 2013 — filed under rhetoric

Dreher has this post on how the “Western world” would react if an African pope is elected. It’s wonderful. There’s this amazing panoply of rhetorical amazingness within. It’s primarily a blockquote of something Mark Shea wrote, wrapped in more fireworks.

First, I love the use of the ...

Read More

more economics-speak

Sat 23 February 2013 — filed under rhetoric

From Modeled Behavior, again:

Imagine if tomorrow we produced the optimal education system and elevated all workers to their highest and most economic valuable level of human capital possible. Does this mean that we would no longer need immigrants or guest-workers? No, the economy is not a peg-board full of ...

Read More

introvert.net © ted whalen Powered by Pelican and tufte-css. Icons by Font Awesome and Font Awesome More