Skip to content

Instantly share code, notes, and snippets.

Thomas Gratier ThomasG77

Block or report user

Report or block ThomasG77

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ThomasG77
ThomasG77 / countTiles.py
Created Jan 25, 2012 — forked from andrewharvey/countTiles.py
Given a WGS84 bounding box and an OSM tile zoom range calculates a total number of tiles.
View countTiles.py
#!/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 / dict_zip
Last active Jan 22, 2020
Javascript equivalent to python dict(zip(['AB', 'CD', 'EF', 'GH'],[1, 2, 3, 4])) - 2 js arrays to one js object
View dict_zip
var keys = ['AB', 'CD', 'EF', 'GH'];
var values = [1, 2, 3, 4];
// Equivalent to python dict(zip(['AB', 'CD', 'EF', 'GH'],[1, 2, 3, 4])) in javascript
function dictZip(key_array, val_array) {
if (key_array.length === val_array.length) {
return key_array.reduce((acc, curr, index) => {
acc[curr] = val_array[index];
return acc;
}, {});
@ThomasG77
ThomasG77 / get_ortho_nantes.py
Created Apr 4, 2012
Orthophotos nantes telecahrgement et decompression
View get_ortho_nantes.py
#!/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 Apr 4, 2012
Liste fichiers orthophotos nantes 2005
View liste_ortho_nantes_2005.txt
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 / postgis_geojson.php
Created Sep 21, 2012 — forked from bmcbride/postgis_geojson.php
PHP PostGIS to GeoJSON
View postgis_geojson.php
<?php
header('Content-Type: application/json; charset=UTF-8');
/**
* PostGIS to GeoJSON
* Query a PostGIS table or view and return the results in GeoJSON format, suitable for use in OpenLayers, Leaflet, etc.
*
* @param string $geotable The PostGIS layer name *REQUIRED*
* @param string $geomfield The PostGIS geometry field *REQUIRED*
* @param string $srid The SRID of the returned GeoJSON *OPTIONAL (If omitted, EPSG: 4326 will be used)*
* @param string $fields Fields to be returned *OPTIONAL (If omitted, all fields will be returned)* NOTE- Uppercase field names should be wrapped in double quotes
@ThomasG77
ThomasG77 / index.html
Last active Dec 18, 2015
OpenLayers zoom level display
View index.html
<!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 / rename_invalid_characters_linux.sh
Last active Dec 19, 2015
How to deal with renaming invalid UTF8 characters in directories or files
View rename_invalid_characters_linux.sh
## Reminder to deal with renaming invalid UTF8 characters (if you are using latin-1 also called iso-8859-1)
## Sources: http://unix.stackexchange.com/questions/6460/bulk-rename-or-correctly-display-files-with-special-characters
## To use it, do a chmod +x rename_invalid_characters_linux.sh; and after do ./rename_invalid_characters_linux.sh your_dir_where_you_want_to_scan_and_rename
# First command to add
grep-invalid-utf8 () {
perl -l -ne '/^([\000-\177]|[\300-\337][\200-\277]|[\340-\357][\200-\277]{2}|[\360-\367][\200-\277]{3}|[\370-\373][\200-\277]{4}|[\374-\375][\200-\277]{5})*$/ or print'
}
@ThomasG77
ThomasG77 / dem_eu
Created Nov 30, 2013
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
View dem_eu
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 / index.html
Last active Jul 27, 2016
Proj4js conversion using Lambert 93 and the new proj4js API (v2.x)Open your JavaScript console to see the result
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>proj4js v2 example </title>
</head>
<body>
<script src="//cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.2/proj4.js" type="text/javascript"></script>
View shapely_benchmarks.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.