Skip to content

Instantly share code, notes, and snippets.

View tbuckl's full-sized avatar
Studying

Tom Buckley tbuckl

Studying
View GitHub Profile
---
title: Spatial Queries on a Feature Layer
description: Create detailed spatial queries like point within polygon or line intersects polygons with Feature Layer queries. Some combinations will not result in any features being highlighted.
layout: example.hbs
---
<!DOCTYPE html>
<html>
<head>
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />

Travel Time and Distance with Google Maps API (and a CSV)

You're probably better off just using this: the python library used there seems to handle errors better https://gist.github.com/buckleytom/0ecfbbb546913c7d9814

However, if you really want to:

This script uses RCurl and RJSONIO to download data from Google's API to get the travel time and distance between latitudes and longitudes by mode, based on some data in a csv

@tbuckl
tbuckl / google_maps_directions_api
Last active August 29, 2015 14:17
google_maps_directions_api
import googlemaps
import os
import csv
import pandas
from array import array
import numpy as np
gmaps = googlemaps.Client(key=os.environ['GMAPSKEY'])
df_s = pandas.io.parsers.read_csv('tripdata.csv',sep=',')
@tbuckl
tbuckl / gist:34fdcd9b8f38fdef7c61
Created May 27, 2015 22:35
pip freeze on deblasio vm
Cython==0.21
DataShape==0.3.0
Flask==0.10.1
GeoAlchemy2==0.2.4
Jinja2==2.7.3
MarkupSafe==0.23
PIL==1.1.7
PyYAML==3.11
Pygments==1.6
SQLAlchemy==0.9.7
@tbuckl
tbuckl / urbansim_notes.md
Last active September 4, 2015 18:35
notes on using urbansim

The reader is advised to check out the official docs first, which are more comprehensive and accurate https://udst.github.io/urbansim/examples.html

Regression Example

One of the features of UrbanSim is regression.

Here we provide an example of how to write the configuration that allows you to tinker with the regression for residential property values in UrbanSim for the SF Bay Area.

At the end you should be able to change the specification for regression for residential housing (hedonic regression). While its not required for you to have used R before, we occasionally refer to R's lm function , because its a standard that many people are familiar with.

@tbuckl
tbuckl / compare_csv_headers.py
Last active September 4, 2015 18:42
Compare the headers in 2 csv files with python
import csv
file1 = "fromAbag.csv"
file2 = "tazData2010.csv"
def sort_lowercase_headers(csvfile):
csvreader = csv.reader(csvfile, delimiter=',',quotechar='|')
header=csvreader.next()
header.sort()
header = [x.lower() for x in header]
return header
[
{
"url": "https://api.github.com/repos/MetropolitanTransportationCommission/bayarea_urbansim/pulls/124",
"id": 63919159,
"html_url": "https://github.com/MetropolitanTransportationCommission/bayarea_urbansim/pull/124",
"diff_url": "https://github.com/MetropolitanTransportationCommission/bayarea_urbansim/pull/124.diff",
"patch_url": "https://github.com/MetropolitanTransportationCommission/bayarea_urbansim/pull/124.patch",
"issue_url": "https://api.github.com/repos/MetropolitanTransportationCommission/bayarea_urbansim/issues/124",
"number": 124,
"state": "closed",
@tbuckl
tbuckl / index.html
Last active May 21, 2017 21:43
Bay Area Bathymetry
<!DOCTYPE html>
<html>
<head>
<title>Ocean</title>
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet.css" />
<script src="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet-src.js"></script>
<!-- Load Esri Leaflet from CDN -->
<script src="https://cdn.jsdelivr.net/leaflet.esri/2.0.2/esri-leaflet.js"></script>
@tbuckl
tbuckl / sspd.py
Created November 17, 2016 23:24
pandas utils for smartsheets
from smartsheet import *
import pandas as pd
from credentials import smartsheet_token
smartsheet = smartsheet.Smartsheet(smartsheet_token)
def get_sheet_as_df(sheet_id):
ss1 = smartsheet.Sheets.get_sheet(sheet_id, page_size=0)
row_count = ss1.total_row_count
ss1 = smartsheet.Sheets.get_sheet(sheet_id, page_size=row_count)
<html>
<head>
<title>Source Zoning Data</title>
<body>this is an empty page that will be used to redirect to a map in the future</body>