Skip to content

Instantly share code, notes, and snippets.

View ThomasG77's full-sized avatar

Thomas Gratier ThomasG77

View GitHub Profile
@ThomasG77
ThomasG77 / countTiles.py
Created January 25, 2012 17:20 — forked from andrewharvey/countTiles.py
Given a WGS84 bounding box and an OSM tile zoom range calculates a total number of tiles.
#!/usr/bin/python
# This script should be considered CC0 licensed
# the deg2num function is from http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#lon.2Flat_to_tile_numbers_2
import math
def deg2num(lat_deg, lon_deg, zoom):
lat_rad = math.radians(lat_deg)
n = 2.0 ** zoom
xtile = int((lon_deg + 180.0) / 360.0 * n)
@ThomasG77
ThomasG77 / get_ortho_nantes.py
Created April 4, 2012 21:42
Orthophotos nantes telecahrgement et decompression
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import requests, re, os
def download_file(url, fileName=None):
def getFileName(url, req):
h = req.headers
file = None;
if h.has_key("content-disposition") and h.get("content-disposition")!= None and 'filename=' in h.get("content-disposition"):
@ThomasG77
ThomasG77 / liste_ortho_nantes_2005.txt
Created April 4, 2012 21:59
Liste fichiers orthophotos nantes 2005
http://data.nantes.fr/fileadmin/data/datastore/3-publication/_orthophoto_/nantesmetropole_ortho_2005_1327_6243.zip
http://data.nantes.fr/fileadmin/data/datastore/3-publication/_orthophoto_/nantesmetropole_ortho_2005_1328_6242.zip
http://data.nantes.fr/fileadmin/data/datastore/3-publication/_orthophoto_/nantesmetropole_ortho_2005_1328_6243.zip
http://data.nantes.fr/fileadmin/data/datastore/3-publication/_orthophoto_/nantesmetropole_ortho_2005_1328_6244.zip
http://data.nantes.fr/fileadmin/data/datastore/3-publication/_orthophoto_/nantesmetropole_ortho_2005_1329_6241.zip
http://data.nantes.fr/fileadmin/data/datastore/3-publication/_orthophoto_/nantesmetropole_ortho_2005_1329_6242.zip
http://data.nantes.fr/fileadmin/data/datastore/3-publication/_orthophoto_/nantesmetropole_ortho_2005_1329_6243.zip
http://data.nantes.fr/fileadmin/data/datastore/3-publication/_orthophoto_/nantesmetropole_ortho_2005_1329_6244.zip
http://data.nantes.fr/fileadmin/data/datastore/3-publication/_orthophoto_/nantesmetropole_ortho_2005_133
@ThomasG77
ThomasG77 / osm.xml
Created December 1, 2015 04:47
Default file for adding OSM background in QGIS
<GDAL_WMS>
<Service name="TMS">
<ServerUrl>http://tile.openstreetmap.org/${z}/${x}/${y}.png</ServerUrl>
</Service>
<DataWindow>
<UpperLeftX>-20037508.34</UpperLeftX>
<UpperLeftY>20037508.34</UpperLeftY>
<LowerRightX>20037508.34</LowerRightX>
<LowerRightY>-20037508.34</LowerRightY>
<TileLevel>18</TileLevel>
@ThomasG77
ThomasG77 / index.html
Last active December 18, 2015 04:29
OpenLayers zoom level display
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers Basic OSM Example with zoom level display</title>
<link rel="stylesheet" href="http://www.openlayers.org/dev/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="http://www.openlayers.org/dev/examples/style.css" type="text/css">
<style>
@ThomasG77
ThomasG77 / dem_eu
Created November 30, 2013 19:44
Get each individual EU-DEM tiles from http://www.eea.europa.eu with a batch. You need wget (apt-get install wget for Ubuntu/Debian or on Windows go to http://gnuwin32.sourceforge.net/packages/wget.htm for installing) After, just do in command-line wget -c -i dem_eu.txt
http://published-files.eea.europa.eu/eudem/jrc_r_3035_25_m_gsgrda-eudem-dem-europe_2012_rev1/eudem_tiles_1000km/EUD_CP-DEMS_2500015000-AA.tif
http://published-files.eea.europa.eu/eudem/jrc_r_3035_25_m_gsgrda-eudem-dem-europe_2012_rev1/eudem_tiles_1000km/EUD_CP-DEMS_2500025000-AA.tif
http://published-files.eea.europa.eu/eudem/jrc_r_3035_25_m_gsgrda-eudem-dem-europe_2012_rev1/eudem_tiles_1000km/EUD_CP-DEMS_2500035000-AA.tif
http://published-files.eea.europa.eu/eudem/jrc_r_3035_25_m_gsgrda-eudem-dem-europe_2012_rev1/eudem_tiles_1000km/EUD_CP-DEMS_2500045000-AA.tif
http://published-files.eea.europa.eu/eudem/jrc_r_3035_25_m_gsgrda-eudem-dem-europe_2012_rev1/eudem_tiles_1000km/EUD_CP-DEMS_2500055000-AA.tif
http://published-files.eea.europa.eu/eudem/jrc_r_3035_25_m_gsgrda-eudem-dem-europe_2012_rev1/eudem_tiles_1000km/EUD_CP-DEMS_3500015000-AA.tif
http://published-files.eea.europa.eu/eudem/jrc_r_3035_25_m_gsgrda-eudem-dem-europe_2012_rev1/eudem_tiles_1000km/EUD_CP-DEMS_7500015000-AA.tif
http://published-files.eea.eur
@ThomasG77
ThomasG77 / github_to_npm.sh
Created February 9, 2016 23:06
Prepare Github repo to manage npmjs release publication
# Mainly inspired by http://mclear.co.uk/2013/10/06/publishing-to-npm-on-git-commit-using-github-hooks-and-travis/
# One shot for installation: uncomment below 3 lines
# sudo apt-get install rubygems
# sudo gem install json
# gem install travis
key="your_key" # Obtained from ~/.npmrc
email="your_mail" # Obtained from ~/.npmrc
base_url_project_github="git@github.com:kosmtik/"
plugins="kosmtik-mbtiles-export kosmtik-map-compare kosmtik-overpass-layer kosmtik-fetch-remote kosmtik-tiles-export kosmtik-geojson-overlay kosmtik-overlay kosmtik-mapnik-reference kosmtik-deploy kosmtik-place-search kosmtik-open-in-josm kosmtik-osm-data-overlay"
@ThomasG77
ThomasG77 / index.html
Created February 19, 2016 23:45 — forked from nolanlawson/index.html
Minimal WebWorker example
<html>
<body>
<h1>Minimal WebWorker example</h1>
<p>Look in the console!</p>
<script src="main.js"></script>
</body>
</html>
@ThomasG77
ThomasG77 / gdal_transform_extent_to_epsg3857.py
Last active February 23, 2016 22:40
Translate extent to use with gdal_translate
# coding: utf-8
import subprocess
import sys
import getopt
import math
# Formulas from http://wiki.openstreetmap.org/wiki/Mercator#Python_Implementation
def merc_x(lon):
r_major = 6378137.000
@ThomasG77
ThomasG77 / request_to_adresse_data_gouv_fr_api.py
Created March 17, 2016 15:22
Python sample to call to adresse.data.gouv.fr
# coding: utf-8
"""Call to adresse.data.gouv.fr API."""
import codecs
import io
from collections import OrderedDict
import requests
requests_session = requests.Session()