Skip to content

Instantly share code, notes, and snippets.

@Hoedic
Hoedic / Analyse-taxe-Montreal.sql
Created May 31, 2022 00:49
Étapes des traitements de données réalisés pour le billet de blogue d'analyse des données de taxe de la ville de Montréal: https://dataholic.ca/2022/05/30/analyse-fonciere-Montreal. Il s'agit là des principales étapes, certaines étapes comme les créations d'index ou certaines assignations simples peuvent manquer.
/*
Etape préparatoire: charger les données
Pour les fichiers shapefile, on utilise shp2pgsql
shp2pgsql -s 2950 geobase_mtl.shp geobase | psql -U user -d db_name
shp2pgsql -s 3857 demo2016_ad_mtl_island.shp stats_socio | psql -U user -d db_name
Pour la valeur d'évaluation foncière venant de CSV, il faut créer la table et les importer fichier par fichier:
@Hoedic
Hoedic / ckan_export.sh
Created February 8, 2016 03:16
Export data from donnees.ville.montreal.qc.ca into a CSV using ckanapi-exporter
ckanapi-exporter --url 'http://donnees.ville.montreal.qc.ca' \
--column "id" --pattern '^name$' \
--column "nom" --pattern '^title$' \
--column "date_creation" --pattern '^metadata_created$' \
--column "derniere_modification" --pattern '^metadata_modified$' \
--column "unite_administrative" --pattern '^author_unite_admin$' \
--column "frequence" --pattern '^update_frequency$' \
--column "nb_fichiers" --pattern '^num_resources$' \
--column "format_fichiers" --pattern '^resources$' '^format$' --deduplicate \
--column "tags" --pattern '^tags$' '^display_name$' --deduplicate \
import matplotlib.pyplot as plt
import pandas as pd
pd.options.display.mpl_style = 'default'
metadata_gov = pd.Series([3.1, 3.6, 3.8, 3.9, 4.1, 4.4, 4.5, 4.5, 4.5, 4.6, 4.8, 4.9, 5], index=["File size", "Spatial\ncoverage", "Keywords", "License", "Contact\ninformation", "Update\nfrequency", "URL", "Temporal\ncoverage", "Publisher", "Description", "Title", "Last update", "Data format"])
metadata_gov.plot(kind="barh")
consumer_metadata = pd.Series([3.22, 3.44, 3.56, 3.67, 3.89, 3.89, 4, 4.22, 4.56, 4.56, 4.56, 4.67, 4.78], index=["File size", "Contact\ninformation", "Temporal\ncoverage", "Update\nfrequency", "Keywords", "Spatial\ncoverage", "Publisher", "License", "Title", "Data format", "Description", "Last update", "URL"])
consumer_metadata.plot(kind="barh")
@Hoedic
Hoedic / gist:6331576
Created August 25, 2013 02:24
Want to support multiple (large) graphs on open trip planner with Tomcat, you have to increase the heap size at lot (and have a lot of memory...)
#In the tomcat/catalina base directory (/usr/share/tomcat6/bin/ under Ubuntu), create a file setenv.sh (tomcat will automatically read it) and set the following:
export JAVA_OPTS='-Xmx6144M'
#or
export CATALINA_OPTS='-Xmx6144M'
#where 6144M is the size needed... in my case, 6GB.
@Hoedic
Hoedic / gist:5592094
Created May 16, 2013 14:25
Mapbox switcher. Generates a drop down that allow switching a mapbox (or any leaflet map) to another.
<div id='map-ui'>
<select onchange="switchMap()" id="maplist";>
</select>
</div>
<div id='map'></div>
<!--div id='map2'></div-->
<script type='text/javascript'>
//Default center and zoom
var myCenter = [45.50, -73.60];