Skip to content

Instantly share code, notes, and snippets.

View johnjreiser's full-sized avatar

John Reiser johnjreiser

View GitHub Profile
@johnjreiser
johnjreiser / dbfschemacompare.py
Last active January 2, 2016 16:09
Generates a simple report showing matching schemas from a list of DBF files. Useful for seeing if a directory of shapefiles have similar attribute tables.
#!/usr/bin/env python
"""
Generates a simple report showing matching schemas from a list of DBF files.
"""
import sys, os, glob
from dbfpy import dbf
files = []
@johnjreiser
johnjreiser / csv2json.py
Last active December 22, 2015 22:49
script to convert a CSV file to JSON
#!/usr/bin/env python
import csv
import simplejson as json
import sys, os
rows = {}
csvkey = "mun_code"
# csvkey is the CSV column that contains a unique ID
@johnjreiser
johnjreiser / lucode_crosswalk.pgsql
Created July 24, 2013 13:25
PostgreSQL of the Land Use crosswalk table. Useful if you need a complete list of all of the Anderson Level 4 codes and their descriptions used in the State of New Jersey land use data.
CREATE TABLE lucode_crosswalk (
lucode integer NOT NULL PRIMARY KEY,
ludesc varchar(100) NOT NULL,
hltype varchar(30) NOT NULL
);
COMMENT ON TABLE lucode_crosswalk IS 'All available Land Use/Land Cover codes used in the NJ LULC data.';
COMMENT ON COLUMN lucode_crosswalk.lucode IS 'Anderson Level IV Code';
COMMENT ON COLUMN lucode_crosswalk.ludesc IS 'Land use type description';
COMMENT ON COLUMN lucode_crosswalk.hltype IS 'Hasse-Lathrop code classification';
@johnjreiser
johnjreiser / DownloadExtractParcels.py
Last active January 24, 2022 18:46
Script to download the GIS parcel and MOD-IV tax assessor databases from NJGIN, the State of New Jersey's online data and metadata repository. Essex and Middlesex are currently in "draft" form and are available through a separate download on NJGIN.
import urllib, os, sys, zipfile
def download(url,name=""):
if(name == ""):
name = url.split('/')[-1]
webFile = urllib.urlopen(url)
localFile = open(name, 'w')
fname = localFile.name
localFile.write(webFile.read())
webFile.close()
@johnjreiser
johnjreiser / xapi_parser.py
Created May 9, 2012 03:22
Script to merge and convert a series of OpenStreetMap XAPI results into a single tab-delimited file. Keys are retained as additional fields. OSM id, latitude, and longitude are always exported.
#!/usr/bin/env python
# ---------------------------------------------------------------------------
# xapi_parser.py
# Created on: 8 May 2012
# Created by: John Reiser <reiser@rowan.edu>
#
# Script to merge and convert a series of OpenStreetMap XAPI results into a
# single tab-delimited file. Keys are retained as additional fields. OSM id,
# latitude, and longitude are always exported.
#
@johnjreiser
johnjreiser / buildPAMS.py
Created March 26, 2012 16:29
buildPAMS - a function to return a NJ PAMS pin for GIS parcels. Python code for use in ArcGIS.
def buildPAMS(mun, blk, lot, qua=None):
"""Returns a PAMS Pin from three or four cadastre fields."""
if (qua == None) or (qua == ''):
return "%s_%s_%s" % (mun, blk, lot)
else:
return "%s_%s_%s_%s" % (mun, blk, lot, qua)