Skip to content

Instantly share code, notes, and snippets.

View ThomasG77's full-sized avatar

Thomas Gratier ThomasG77

View GitHub Profile
@gzagatti
gzagatti / raster_postgis.py
Last active April 29, 2024 06:51
Loads raster data from POSTGIS directly to numpy.array using rasterio
import psycopg2
from rasterio.io import MemoryFile
conn = pscopg2.connect("<connection string>")
cur = conn.cursor()
# ensure that the GTiff driver is available,
# see https://postgis.net/docs/postgis_gdal_enabled_drivers.html
cur.execute('''
SET postgis.gdal_enabled_drivers TO 'GTiff';
SELECT ST_AsGDALRaster(rast, 'GTiff') FROM raster.table;
@mapsmania
mapsmania / index.html
Last active January 1, 2020 10:47
iiif scroll
<!DOCTYPE html>
<html>
<head>
<link href="https://unpkg.com/leaflet@1.0.2/dist/leaflet.css" rel="stylesheet">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<script src="https://unpkg.com/leaflet@1.0.2/dist/leaflet.js">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="leaflet-iiif.js">
@palmerj
palmerj / mvt_qgis.md
Last active February 20, 2018 02:03
View Vector Tiles in QGIS using GDAL/OGR 2.3

Create mapbox vectors using OGR

Get NZ parcels data over Auckland region in SHP: https://data.linz.govt.nz/x/CLzEZU

Generate vector tiles

ogr2ogr -f MBTILES parcels.mbtiles nz-primary-parcels.shp -dsco MAXZOOM=14
@codan-telcikt
codan-telcikt / geometry_geojson.yaml
Last active September 3, 2023 11:47 — forked from bubbobne/geometry_geojson.yaml
An OpenAPI definition for GeoJSON with Geometry and Features.
# MIT License
#
# Copyright (c) 2017 Daniele Andreis <daniele.andreis@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@ArVan
ArVan / app.js
Last active March 11, 2021 03:06
JWT Authentication with Passport
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var index = require('./routes/index');
var user = require('./routes/user');
var auth = require('./routes/auth');
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active March 30, 2026 15:22
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@mdouchin
mdouchin / PostGIS_create_missing_spatial_indexes.sql
Last active June 16, 2020 21:09
PostGIS - Function to create missing spatial indexes in your whole database
-- Allow to list all layers with no spatial index
-- To get the list
-- SELECT * FROM create_missing_spatial_indexes(True);
-- To create automatically the missing spatial indexes
-- SELECT * FROM create_missing_spatial_indexes(False);
DROP FUNCTION IF EXISTS create_missing_spatial_indexes();
DROP FUNCTION IF EXISTS create_missing_spatial_indexes( BOOLEAN );
CREATE OR REPLACE FUNCTION create_missing_spatial_indexes(simulate BOOLEAN DEFAULT FALSE)
RETURNS TABLE (
@devhero
devhero / py_remote_extract_tar_gzip.py
Last active September 9, 2024 14:06
python download and extract remote file tar.gzip
# Instruct the interpreter to create a network request and create an object representing the request state. This can be done using the urllib module.
import urllib.request
import tarfile
thetarfile = "http://file.tar.gz"
ftpstream = urllib.request.urlopen(thetarfile)
thetarfile = tarfile.open(fileobj=ftpstream, mode="r|gz")
thetarfile.extractall()
# The ftpstream object is a file-like that represents the connection to the ftp server. Then the tarfile module can access this stream. Since we do not pass the filename, we have to specify the compression in the mode parameter.
import requests
import csv
import datetime
import calendar
import time
i=0
# Change the range depending on how long you like to record the data
for i in range (0,50):