This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select co.tags->'ref:INSEE', count(*) as nb from planet_osm_polygon co join planet_osm_polygon epci on (st_overlaps(co.way,epci.way)) where co.admin_level='8' and co.tags ? 'ref:INSEE' and epci.boundary='local_authority' and epci.tags ? 'local_authority:FR' group by 1 order by 2 desc; | |
insee_com | nb | |
----------+---- | |
39537 | 3 | |
14371 | 3 | |
60196 | 2 | |
61050 | 2 | |
61168 | 2 | |
61483 | 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from bs4 import BeautifulSoup | |
carto = BeautifulSoup(open(sys.argv[1]),'xml') | |
total = 0 | |
for style in carto.find_all("Style"): | |
rules = style.find_all("Rule") | |
total = total + len(rules) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: ./addok2xml.sh "39 quai andré citroën Paris" | |
# dépend de: httpie et jq (sudo apt install httpie jq) | |
http "http://api-adresse.data.gouv.fr/search/?limit=1&q=$1" | \ | |
jq --raw-output '"<geo><latitude>\(.features[0].geometry.coordinates[1])</latitude><longitude>\(.features[0].geometry.coordinates[0])</longitude><score>\(.features[0].properties.score)</score><id>\(.features[0].properties.id)</id></geo>"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import sys | |
import requests | |
import json | |
# Usage: python csv2geocode.py inputcsv inputcols geo_cols | |
# Ex: python csv2geocode.py example.csv numero,voie,codep,ville longitude,latitude,score,type,label,citycode | |
cols = sys.argv[2].split(',') | |
print(cols) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This bash script copies pictures from Mapillary folders stored on an iPhone | |
# then update the pictures EXIF data to get the GPS and timestamp | |
# written by Christian Quest - August 2016 | |
# requires jq and exiftool, if missing: apt install jq exiftool | |
# tested on Ubuntu 16.04 | |
# copy Mapillary internal json data (contains GPS info, and more) | |
rsync /run/user/1000/gvfs/afc*/com.mapillary.app/cameras/internal/ internal -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events_what | count | oldest | newest | geometries | |
---|---|---|---|---|---|
air.pollution.level | 170 | 2016-06-06 00:00:00+00 | 2016-08-19 00:00:00+00 | 8 | |
air.pollution.level.warning | 32 | 2016-08-10 00:00:00+00 | 2016-08-19 00:00:00+00 | 8 | |
alert | 4 | 2016-06-07 16:00:00+00 | 2016-06-11 10:42:00+00 | 4 | |
alert.emergency | 19 | 2016-01-07 13:00:00+00 | 2017-07-31 17:00:00+00 | 19 | |
alert.supervision | 2 | 2016-07-29 09:00:00+00 | 2016-07-30 10:00:00+00 | 2 | |
convention | 3 | 2016-05-20 07:00:00+00 | 2016-09-25 16:00:00+00 | 3 | |
culture.arts | 48 | 2015-06-06 12:00:00+00 | 2025-12-31 16:00:00+00 | 25 | |
culture.entertainment | 22 | 2016-07-22 20:30:00+00 | 2016-10-16 17:00:00+00 | 13 | |
culture.music | 3094 | 2016-06-17 14:30:00+00 | 2016-09-22 21:00:00+00 | 2206 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SELECT * FROM db_size; -- list tables/index with the disk space occupied | |
-- SELECT * FROM db_bloat; -- compute lost space in data/index | |
-- SELECT * FROM db_stats; -- show size of data/index + number of reads (data) or index scans | |
-- SELECT * FROM db_index_list ; -- show original CREATE INDEX statement | |
CREATE OR REPLACE VIEW db_bloat AS | |
SELECT current_database() AS current_database, | |
sml.schemaname, | |
sml.tablename, | |
round( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select count(*), sum(st_length(st_transform(r.way,4326)::geography)), r.service from planet_osm_line r join planet_osm_polygon p on (st_intersects(r.way,p.way)) where r.railway='rail' and p.osm_id=-2202162 group by 3; | |
count | sum | service | |
-------+------------------+-------------- | |
54495 | 52672699.848765 | | |
6 | 863.600613716276 | industrial | |
18 | 31704.5442901028 | main | |
657 | 63642.8733992808 | crossover | |
14463 | 5710487.2771534 | yard | |
10976 | 4281735.35639498 | spur |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* changements heure hiver > été depuis 1981 le dernier dimanche de mars à 1h UTC soit 2h (hiver) / 3h (été) en France */ | |
select april::timestamptz | |
- interval '1 day' * case when extract(dow from april)=0 then 7 else extract(dow from april) end | |
from (select generate_series('1981-04-01 01:00:00+00','2050-04-01 01:00:00+00', interval '1 year') as april) as m; | |
/* changements heure été > hiver de 1981 à 1995 le dernier dimanche de septambre à 1h UTC soit 2h (hiver) / 3h (été) en France */ | |
select sept::timestamptz | |
- interval '1 day' * case when extract(dow from sept)=0 then 7 else extract(dow from sept) end | |
from (select generate_series('1981-10-01 01:00:00+00','1995-10-01 01:00:00+00', interval '1 year') as sept) as m; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEP | ANNEE | RESOLUTION | |
---|---|---|---|
01 | 2012 | 20CM | |
02 | 2013 | 20CM | |
03 | 2013 | 20CM | |
04 | 2012 | 20CM | |
05 | 2013 | 50CM | |
06 | 2012 | 20CM | |
07 | 2014 | 50CM | |
08 | 2013 | 50CM | |
09 | 2013 | 50CM |