Skip to content

Commit

Permalink
some comments and year2000 shapefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jrising committed Jun 12, 2015
1 parent 05c1eb9 commit 6a7c3e6
Show file tree
Hide file tree
Showing 9 changed files with 1,096 additions and 0 deletions.
5 changes: 5 additions & 0 deletions getvalues.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
################################################################################
# getvalues - Construct a CSV-formatted list of values for all present-day
# regions, using a historical shapefile and historical values file.
################################################################################

import sys, csv
import shapefile
import shapelogic
Expand Down
8 changes: 8 additions & 0 deletions shapelogic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
################################################################################
# shapelogic - Helper functions for using shapefiles with shapely
################################################################################

import shapefile
from shapely.geometry import Polygon, MultiPolygon, geo

def shape2parts(shape):
"""Divide a shape's points based on the indexes in <parts>."""
parts = []
start_indexes = shape.parts
prev_start_index = 0
Expand All @@ -13,6 +18,7 @@ def shape2parts(shape):
return parts

def shape2multi(shape):
"""Construct a Polygon for each of a shape's parts, and a MultiPolygon to wrap it all."""
parts = shape2parts(shape)
polygons = []
for part in parts:
Expand All @@ -21,11 +27,13 @@ def shape2multi(shape):
return MultiPolygon(polygons)

def intersection(one, two):
"""Construct an intersection polygon for two shapefile shapes."""
onepoly = shape2multi(one)
twopoly = shape2multi(two)

return onepoly.intersection(twopoly)

def box_intersects(one, two):
"""Return true if two boxes (as vectors of xmin, ymin, xmax, ymax) intersect."""
return geo.box(*one).intersects(geo.box(*two))

Binary file added year2000/US_county_2000.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions year2000/US_county_2000.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["USA_Contiguous_Albers_Equal_Area_Conic",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-96.0],PARAMETER["Standard_Parallel_1",29.5],PARAMETER["Standard_Parallel_2",45.5],PARAMETER["Latitude_Of_Origin",37.5],UNIT["Meter",1.0]]
Binary file added year2000/US_county_2000.sbn
Binary file not shown.
Binary file added year2000/US_county_2000.sbx
Binary file not shown.
Binary file added year2000/US_county_2000.shp
Binary file not shown.
1,082 changes: 1,082 additions & 0 deletions year2000/US_county_2000.shp.xml

Large diffs are not rendered by default.

Binary file added year2000/US_county_2000.shx
Binary file not shown.

0 comments on commit 6a7c3e6

Please sign in to comment.