Playing with Python Rasterstats

This is code to get PctAg and PctUrb using NLCD 2006 for US Counties. First we’ll import some libraries. import pandas as pd import numpy as np import geopandas as gp Bring in US Counties using US Census counties shapefile counties = gp.GeoDataFrame.from_file('L:/Priv/CORFiles/Geospatial_Library/Data/RESOURCE/POLITICAL/BOUNDARIES/NATIONAL/Counties_Census_2010.shp') list(counties) counties.STATE_NAME.unique() counties = counties[(counties.STATE_NAME != 'Hawaii') & (counties.STATE_NAME != 'Alaska')] counties = counties[['FIPS','NAME','geometry']] counties.head() .dataframe thead tr:only-child th { text-align: right; } . [Read More]

GeoPandas Tutorial

This is an implementation of the excellent PostGIS / geopandas tutorial here using NHDPlus WBD polygons for PNW. All the ideas and methods are from this tutorial, simply implementing with a different dataset and in Oregon. %matplotlib inline import os import json import psycopg2 import matplotlib.pyplot as plt # The two statemens below are used mainly to set up a plotting # default style that's better than the default from matplotlib import seaborn as sns plt. [Read More]

Wordcloud

I’ve been toying with building a wordcloud of all my publications in both R and python on and off for some time, and while there’s a really nice R library for doing this wordcloud2, this example uses wordcloud, a python word cloud generator. I pasted all my publications into a single text file which is read into python and used by wordcloud as shown in code and results below. from os import path from wordcloud import WordCloud # Read the whole text. [Read More]