Skip to content

Instantly share code, notes, and snippets.

{
"address": {
"administrative": "Paris",
"city": "Paris",
"country": "France",
"country_code": "fr",
"county": "Paris",
"postcode": "75004",
"road": "Rue des Francs Bourgeois",
"state": "\u00cele-de-France",
select
(select count(1) from acls) as acls,
(select count(1) from changeset_tags) as changeset_tags,
(select count(1) from changesets) as changesets,
(select count(1) from client_applications) as client_applications,
(select count(1) from countries) as countries,
(select count(1) from current_node_tags) as current_node_tags,
(select count(1) from current_nodes) as current_nodes,
(select count(1) from current_relation_members) as current_relation_members,
(select count(1) from current_relation_tags) as current_relation_tags,
@zhm
zhm / osmtag.sh
Created October 5, 2012 15:02
Make a quick CSV from any tag/value in OSM
TAG="amenity" && VALUE="baby_hatch" && curl -s "http://overpass-api.de/api/interpreter?data=%5Bout%3Ajson%5D%3B%28node%5B${TAG}%3D%27${VALUE}%27%5D%3B%29%3Bout%3B" | grep -E "lat|lon" | sed 's/"//g' | sed -E 's/lat: (.+),/\1|/' | sed 's/lon: //' | sed 's/ //' | xargs | tr ',' '\n' | tr '|' ',' | sed 's/ //g' | grep -Ev '^$'
@zhm
zhm / mbtiles_delete_zoom_level.sql
Created October 3, 2012 23:09
Delete zoom levels from an MBTiles file (set max zoom)
-- change 18 to whatever the max zoom level you want in your MBTiles
DELETE FROM images WHERE
tile_id IN (SELECT tile_id FROM map WHERE zoom_level > 18) AND
tile_id NOT IN (SELECT tile_id FROM map WHERE zoom_level <= 18);
DELETE FROM map WHERE zoom_level > 18;
UPDATE metadata SET value = '18' WHERE name = 'maxzoom';
@zhm
zhm / patch_filegdb_dylibs.sh
Created July 18, 2012 05:22
Patch ESRI FileGDB dylibs
$ install_name_tool -id "$(pwd)/lib/libFileGDBAPI.dylib" ./lib/libFileGDBAPI.dylib
$ install_name_tool -change "@rpath/libfgdbunixrtl.dylib" "$(pwd)/lib/libfgdbunixrtl.dylib" ./lib/libFileGDBAPI.dylib
$ install_name_tool -id "$(pwd)/lib/libfgdbunixrtl.dylib" ./lib/libfgdbunixrtl.dylib
@zhm
zhm / osmstats.sh
Created June 25, 2012 02:15
osmstats
OSMUSER="coleman"; curl -s "www.overpass-api.de/api/interpreter?data=%5Bout%3Ajson%5D%3B%28node%28user%3A%22$OSMUSER%22%29%3Bway%28user%3A%22$OSMUSER%22%29%3Brelation%28user%3A%22$OSMUSER%22%29%3B%29%3Bout%3B" | ruby -e "require 'json'; osm = JSON.parse(STDIN.read); nodes = osm['elements'].select {|e| e['type'] == 'node'}; ways = osm['elements'].select {|e| e['type'] == 'way'}; relations = osm['elements'].select {|e| e['type'] == 'relation'}; puts ''; puts 'stats for $OSMUSER:'; puts 'nodes: ' + nodes.count.to_s; puts 'ways: ' + ways.count.to_s; puts 'relations: ' + relations.count.to_s; puts ''"
@zhm
zhm / configure.in
Created May 24, 2012 20:40
configure.in for GDAL 1.9.1
dnl ***************************************************************************
dnl $Id: configure.in 24333 2012-04-28 12:18:28Z rouault $
dnl
dnl Project: GDAL
dnl Purpose: Configure source file.
dnl Author: Frank Warmerdam, [email protected]
dnl
dnl ***************************************************************************
dnl Copyright (c) 2000, Frank Warmerdam
dnl
@zhm
zhm / gdal_with_ruby.sh
Created May 17, 2012 20:52
GDAL w/ Ruby
./configure \
--with-local=yes \
--prefix=$HOME/local \
--with-threads \
--with-libtool \
--with-libtiff=internal \
--with-geotiff=internal \
--with-pcraster=internal \
--with-pcidsk=internal \
--with-libz=/usr \
@zhm
zhm / gist:2005158
Last active February 28, 2022 17:11
Building GDAL 1.9 with ESRI FileGDB support on OS X Lion

Building GDAL 1.9.x with ESRI FileGDB support on OS X Lion

  • Download the SDK from ESRI's website http://resources.arcgis.com/content/geodatabases/10.0/file-gdb-api
  • Extract the SDK, and put the contents of the directory in a known location, I used ~/local/filegdb. Here's an example path to one of the files: ~/local/filegdb/lib/libFileGDBAPI.dylib
  • I use ~/local/filegdb so it can stay isolated in it's own place. You can put it anywhere, but the next few steps might be different.
  • Go into the directory containing the FileGDB SDK, e.g. ~/local/filegdb
  • ESRI built these dylib's using @rpath's, so to avoid needing to mess with DYLD_LIBRARY_PATH, I updated the @rpath's using install_name_tool. There might be a more elegant way to handle this. If so, comments are welcome!
  • Here are the commands I used to patch the dylibs, this is not required if you want to use DYLD_LIBRARY_PATH yourself:
install_name_tool -id "$(pwd)/lib/libFileGDBAPI.dylib" ./lib/libFileGDBAPI.dylib
install_name_tool -change "@rpath/libfgdbunixrtl.dylib" "$(pwd)/lib/libfgdbunixrtl.dylib" ./lib/libFileGDBAPI.dylib
install_name_tool -id "$(pwd)/lib/libfgdbunixrtl.dylib" ./lib/libfgdbunixrtl.dylib