Skip to content

Instantly share code, notes, and snippets.

@talos
talos / grid.sql
Created September 27, 2016 15:31
Create a grid in PostGIS for CARTO based off of arbitrary envelope and Projection
INSERT INTO <my_table_name> (cartodb_id, the_geom, the_geom_webmercator)
WITH inputs AS (SELECT
ST_Transform(ST_SetSRID(ST_MakeEnvelope(
-126.21093749999999, 23.241346102386135,
-63.28125, 50.064191736659104
), 4326), 5070) geom,
500000 width,
500000 height
), rast AS (SELECT
(st_pixelaspolygons(
@talos
talos / gist:090bc270219e34128cd9754215502e48
Created May 19, 2016 15:54
NYS grocery store analysis
INSERT INTO jkrauss.untitled_table(the_geom, name)
SELECT *
FROM OBS_GetBoundariesByGeometry(
(SELECT ST_SetSRID(ST_MakeEnvelope(
MIN(ST_X(the_geom)),
MIN(ST_Y(the_geom)),
MAX(ST_X(the_geom)),
MAX(ST_Y(the_geom))
), 4326) FROM jkrauss.retail_food_stores_fixed),
'us.census.tiger.puma_clipped'
@talos
talos / kill_obs_functions.sql
Created April 13, 2016 19:33
kill_obs_functions
CREATE OR REPLACE FUNCTION kill_obs_functions(
) RETURNS void
AS $$
DECLARE
killselect TEXT;
BEGIN
FOR killselect in SELECT 'DROP FUNCTION ' || ns.nspname || '.' || proname || '(' ||
oidvectortypes(proargtypes) || ');'
FROM pg_proc

Step 1: Adjust the income and expenses reported by the property being valued

  • We adjust a property’s reported income and expenses in a variety of ways to capture market conditions. We also strive to protect property owners from spikes or sharp decreases in value based on one year’s data. Below are a few adjustments:

    • Trending: We project a property’s income and expense to the taxable status date (January 5th) from data filed in the previous year and reported for the year before that. So for tax year 2015-2016, which had a taxable status date of January 5, 2015, RPIEs were filed by owners in 2014 and owners reported data for 2013.

    • Addbacks for vacancies and owner occupancy: We add on income for vacancy levels in a property beyond what is typical and for owner-occupied portions of a property that don’t generate income but potentially could.

    • Lease termination income: We cap the percentage of income for payments for leases being terminated by renters.

@talos
talos / index.html
Last active March 15, 2016 20:03
Airbnb / Sq. Mile vs. % Airbnb
This file has been truncated, but you can view the full file.
<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>/**
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
@talos
talos / index.html
Last active March 3, 2016 22:40
Nightly Price vs. Days to Pay Rent
<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>/**
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
@talos
talos / .gitignore
Last active February 26, 2016 21:13
Median Rent vs Days to Make Rent
bower_components/*
@talos
talos / index.html
Last active February 26, 2016 21:02
airbnb per sq mile vs. % airbnb
<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css">
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script>
<title></title>
@talos
talos / sample-bigmetadata.sql
Created February 18, 2016 10:00
Sample queries to obtain tables relevant for a resolution, then columns in a tag for that resolution.
/* Determine tablenames for data at a specific resolution.
*/
/* data_table_id: ID to use to find columns in data tables at this resolution
* from_tablename: data table with data specified resolution
* from_column: column to use when joining against the data table
* to_tablename: table with geom data
* to_column: column to use when joining against the geom table
* geom_column: column containing geom data
*/
@talos
talos / join.py
Created January 22, 2016 01:15
Sample of joining together yelp review & business data
import json
def main():
businesses_by_id = {}
with open('yelp_academic_dataset_business.json') as business_file:
# for every line in this file (every business)
# load the json in from that line into an object (json.loads)
#
# save the object to the businesses_by_id dict by its `business_id`