Skip to content

Instantly share code, notes, and snippets.

@BGranberg
BGranberg / C:\projects\uspszip\gcuspszip5_needs work.py
Created December 23, 2013 23:40
Work in Progress! Concept: - Get a street delivery mail zip+4 record from an Access database prepared by the Tax Commission from the USPS address information system (AIS) db (there are several tables, one fore each zip+4s for each unque first three zip code digits (840,841, 842, etc) note 842 is the IRS in ogden (all po boxes...not a good test 8…
# Utah Street Address Locator (Geocoding) Service
# AGRC, 20130329
# WHAT?
# Geocodes an input table in one of the arcgis-compatible file formats and produces
# an new output .csv table with the geocoded results
# IMPORTANT NOTES:
#
# individualized api key will be required in near future, here's how to get one:
@BGranberg
BGranberg / Convert Drive Test Data to GDB.py
Last active December 31, 2015 21:28
Convert Isotrope Broadband Drive Test files (2013) to fileGDB feature classes
import arcpy
import os
from os import listdir
import csv
def find_csv_filenames( path_to_dir, suffix=".csv" ):
filenames = listdir(path_to_dir)
return [ filename for filename in filenames if filename.endswith( suffix ) ]
@BGranberg
BGranberg / SBI Community Broadband Overview.py
Created October 15, 2013 17:15
This script uses ESRI ArcMap spatial queries to look at the highest advertised download speed and number of providers (for mobile and fixed wireless technologies separately) within each Census designated community area polygon for Utah. Data is generated in a .csv table for a single NTIA broadband submission period. Running the script against tw…
import arcpy
import csv
from arcpy import da
arcpy.env.overwriteOutput = True
bbRound= '8'
bbGeodatabaseLocation = r'Database Connections\ubbadmin@ubbmap@gdb10.agrc.utah.gov.sde'
##bbGeodatabaseLocation = r'I:\PROJECTS\Broadband\Round2 Submission\UT_SBDD_20101011.gdb\NATL_Broadband_Map'
@BGranberg
BGranberg / Geocode a Table of Utah Addresses
Last active August 7, 2017 21:01
For Utah Addresses: This code will geocodes an input table in one of the arcgis-compatible file formats (.csv, .dbf, .xls. .gdb, etc) and produces # an new output .csv table with the geocoded results. Uses AGRC statewide geocoding web service
# Utah Street Address Locator (Geocoding) Service
# AGRC, 20131220
# WHAT?
# Geocodes an input table in one of the arcgis-compatible file formats and produces
# an new output .csv table with the geocoded results
# IMPORTANT NOTES:
#
# individualized api key will be required in near future, here's how to get one:
@BGranberg
BGranberg / Export Utah SGID ArcSDE Data To File Packages.py
Created July 25, 2012 21:32
Export a group of feature classes (stored in ArcSDE) using a specified JSON structured text file as the input parameter. This script will build packaged and unpackaged zipped shape and zipped file geodatabase files, a folder structure, and a .bat file for
#20120725_15:23pm
#working but in need of future refactoring (ex. change .bat to .py?)
#Runs off a locally stored .txt file containing JSON objects
#Writes zipped statewide gdb and shp data to outputRoot
#Writes .bat file with time stamp for replacing existing ftp site content
# jsonPackagesfile is a JSON data structure containing package objects. Each data package object
# consists of:
# ["Name"] the output name for the package,
@BGranberg
BGranberg / Truncate and Load ArcSDE 10 Table.py
Created May 23, 2012 22:28
Truncate and Load ArcSDE 10 Table.py - Copy and paste this script into notepad. Then set the sourceDataFullPath and updateDataFullPath variables appropriately and save the file. Schemas have to match exactly. Also, this script references an SDE connection
import arcpy
arcpy.env.overwriteOutput = True
def fcUpdate(srcTable, tarTable):
tarTableView = arcpy.MakeTableView_management(tarTable,'targetTable')
srcTableView = arcpy.MakeTableView_management(srcTable,'sourceTable')
arcpy.DeleteRows_management(tarTableView)
@BGranberg
BGranberg / USDACommunityConnectScoresFromFCC_NBM_APIs.py
Created May 22, 2012 16:52
USDACommunityConnectScoresFromFCC_NBM_APIs.py - This code creates a CSV output file with basic 2010 demographic information for each Census Place community in a state. It also uses this demographic information to calculate the value of two USDA Community
import json
import urllib2
import datetime
from time import strftime
def getEconomicScore(inMedianHouseholdIncome):
#Set this variable from:
#http://www.census.gov/hhes/www/income/data/historical/household/2010/H08_2010.xls
#This data would make a nice web service!