Skip to content

Instantly share code, notes, and snippets.

View pdbartsch's full-sized avatar

Paul Bartsch pdbartsch

  • UC Santa Barbara
  • 93455
View GitHub Profile
@pdbartsch
pdbartsch / gist:2482197
Created April 24, 2012 18:11
TileMill Icons in Legend
<div class='my-legend'>
<div class='title'>Activity Type<br></div>
<div class='scale'>
<ul class='labels'>
<li><img src="https://s3.amazonaws.com/pdb.www/hiking-3.png" />Hiking</li>
<li><img src="https://s3.amazonaws.com/pdb.www/mountainbiking-3.png" />Biking</li>
</ul>
</div>
</div>
@pdbartsch
pdbartsch / gist:2482241
Created April 24, 2012 18:15
TileMill Icons based on type field and zoom level
#activitiesgeojson {
[zoom >= 0][zoom <=10] {
[type = "bike"] {point-file: url(icons/mountainbiking-2.png); }
[type = "hike"] {point-file: url(icons/hiking-2.png); }
}
[zoom = 11] {
[type = "bike"] {point-file: url(icons/mountainbiking-1.png); }
[type = "hike"] {point-file: url(icons/hiking-1.png); }
}
[zoom > 11][zoom <=14] {
--#lowecase table and field names scripts:
--(generates the sql needed; best to do in psql command line)
SELECT 'ALTER TABLE ' || quote_ident(c.table_schema) || '.'
|| quote_ident(c.table_name) || ' RENAME "' || c.column_name || '" TO ' || quote_ident(lower(c.column_name)) || ';' As ddlsql
FROM information_schema.columns As c
WHERE c.table_schema NOT IN('information_schema', 'pg_catalog')
AND c.column_name <> lower(c.column_name)
ORDER BY c.table_schema, c.table_name, c.column_name;
@pdbartsch
pdbartsch / random psql commands #PostGIS
Last active February 16, 2017 15:03
random psql commands
--connect to "specific_database"
psql -d specific_database;
--alter table, change name of table and move to different schema
alter table schema_name.table_name
rename to new_table_name
set schema name_of_new_schema;
--end a psq command
\q
@pdbartsch
pdbartsch / gist:5032363
Last active December 14, 2015 04:59
Overpass export from OpenStreetMap (not working yet)
wget -O buildingSchool.osm http://overpass.osm.rambler.ru/cgi/xapi?node[building=school][bbox=-120.722519,34.288326,-119.405861,35.133329][@meta]
wget -O buildingUniversity.osm http://overpass.osm.rambler.ru/cgi/xapi?node[building=university][bbox=-120.722519,34.288326,-119.405861,35.133329][@meta]
wget -O amenitySchool.osm http://overpass.osm.rambler.ru/cgi/xapi?node[amenity=school][bbox=-120.722519,34.288326,-119.405861,35.133329][@meta]
wget -O amenityUniversity.osm http://overpass.osm.rambler.ru/cgi/xapi?node[amenity=university][bbox=-120.722519,34.288326,-119.405861,35.133329][@meta]
wget -O UCSB_hydrants.osm http://overpass.osm.rambler.ru/cgi/xapi?node[emergency=fire_hydrant][bbox=-119.8908,34.3994,-119.8333,34.4283][@meta]
@pdbartsch
pdbartsch / gist:5043561
Created February 27, 2013 00:01
OpenStreetMap Overpass export example
wget -O UCSB_hydrants.osm http://overpass.osm.rambler.ru/cgi/xapi?node[emergency=fire_hydrant][bbox=-119.8908,34.3994,-119.8333,34.4283][@meta]
@pdbartsch
pdbartsch / gist:5258017
Last active December 15, 2015 12:09
Grab data from OpenStreetMap . Some specific examples that I reuse.
#key = building
wget -O goleta_buildings.osm http://overpass.osm.rambler.ru/cgi/xapi?way[building=yes][bbox=-119.919272,34.401164,-119.802431,34.44535][@meta]
#grabs points
#amenity = school
wget -O SBco_schools.osm http://overpass.osm.rambler.ru/cgi/xapi?node[amenity=school][bbox=-120.701335,34.369261,-119.418620,35.176881][@meta]
#grabs lines and points
#building = school
@pdbartsch
pdbartsch / gist:5259037
Last active December 15, 2015 12:19
My most commonly used bounding boxes.
Santa Barbara County: [bbox=-120.701335,34.369261,-119.418620,35.176881]
UC Santa Barbara: [bbox=-119.8908,34.3994,-119.8333,34.4283]
Goleta: [bbox=-119.919272,34.401164,-119.802431,34.44535]
@pdbartsch
pdbartsch / rename.bat
Last active April 15, 2024 11:50
Windows batch file to change the names of many files based on a csv. The first "column" of the csv contains the old name name with the old file extension. Then second contains the new name with no file extension.
@echo off
setlocal enableDelayedExpansion
REM sets folder to CD (current directory)
SET folder=%CD%
REM if the renamed folder already exists, I'll assume I've already run this script and go to EOF (end of file)
IF EXIST "%folder%\renamed" GOTO :EOF
REM else move on to :FOLDERDOESNOTEXIST
GOTO :FOLDERDOESNOTEXIST
@pdbartsch
pdbartsch / query.sql
Last active December 16, 2015 08:29
Searching gis.stackexchange for users local to me http://data.stackexchange.com/gis/query/108984/users-in-california
-- users in California
-- with a reputation > 1
-- that have accessed site in past year
SELECT
ROW_NUMBER() OVER(ORDER BY Reputation DESC) AS [#],
Id AS [User Link],
Reputation,
Location,
LastAccessDate,