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
# Execute in the PyQGIS console
def showXY(p):
print(p.x(), p.y())
currentCanvas = iface.mapCanvas()
# Below enable to "unregister" listening to click event
# currentCanvas.xyCoordinates.disconnect(showXY)
ThomasG77 / .gitignore
Last active May 4, 2019
Use GDAL2Tiles to view images in Leaflet
View .gitignore
ThomasG77 / index.html
Created May 4, 2019
Leaflet.Spin standalone (similar to official but use only CDNs)
View index.html
<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="" />
<script src=""></script>
<script src="" charset="utf-8"></script>
<script src="" charset="utf-8"></script>
<style type='text/css'>
ThomasG77 /
Created Apr 28, 2019
Take a GeoJSON as an input, take all H3 hexagons within and output GeoJSON hexagons with their id
from h3 import h3
geoJson = {'type': 'Polygon',
'coordinates': [[[37.813318999983238, -122.4089866999972145],
[ 37.7866302000007224, -122.3805436999997056 ],
[37.7198061999978478, -122.3544736999993603],
[ 37.7076131999975672, -122.5123436999983966 ],
[37.7835871999971715, -122.5247187000021967],
[37.8151571999998453, -122.4798767000009008]]] }
ThomasG77 / .gitignore
Last active Apr 28, 2019
Generate H3 hexagons
View .gitignore
# Code borrowed from
# and upgraded for QGIS 3.0
import sys
from qgis.core import (QgsApplication, QgsFeature, QgsGeometry,
QgsProject, QgsVectorLayer)
from qgis.gui import QgsMapCanvas
from qgis.PyQt.QtCore import Qt
# Unused so commented
# from qgis.PyQt.QtGui import *
ThomasG77 /
Created Dec 6, 2018
Démo pour montrer comment reprojeter en EPSG 2154 un CSV issu du géocodage de l'API CSV de
## How to reproject to EPSG 2154
# Get data
cd /tmp/
# Uncompress
# Take only 10 first lines
View index.html
<!doctype html>
This can be used to test the tile serving.
In a browser, open this as a local file.
You will have to start the app server instance without the host option, so that it
will serve as "localhost".
<html lang="en">
<link href="" rel="stylesheet">
ThomasG77 / promise-race.js
Created Aug 28, 2018
Promise.race illustrated with sourceforge mirrors
View promise-race.js
const fetch = require('node-fetch');
const mirrors = ['astuteinternet', 'ayera', 'cfhcable', 'cytranet', 'datapacket', 'excellmedia', 'freefr', 'gigenet', 'iweb', 'jaist', 'kent', 'liquidtelecom', 'managedway', 'nchc', 'netcologne', 'netix', 'newcontinuum', 'phoenixnap', 'pilotfiber', 'razaoinfo', 'superb-dca2', 'superb-sea2', 'svwh', 'tenet', 'ufpr', 'versaweb'];
const url = '';
// Find the fastest Sourceforge mirror manually
// The usual use case would for Promise.race would be
// when calling images from multiple servers
// (imagine different AWS S3 storage) to get the fastest one
var p = Promise.race(
ThomasG77 /
Last active Jul 24, 2018 — forked from rveciana/
Using JSTS to measure how far a line travels through a polygon

Example to ilustrate this question at gis.stackoverflow.

We choose to replace Turf with JSTS.

If the result is more complex (i.e. the resulting intersection is a polyline), the algorithm should be repeated for each part in the polygon.

You can’t perform that action at this time.