Skip to content

Instantly share code, notes, and snippets.


Kevin de Youngster kevin-deyoungster

View GitHub Profile
kevin-deyoungster /
Created Jul 26, 2020
Function to convert GeoJSON feature to H3 cells and vice versa
from h3 import h3
def feature_to_h3set(feature, resolution):
return h3.polyfill(feature["geometry"], resolution, True)
def h3_to_feature(hex_address, properties={}):
coordinates = [h3.h3_to_geo_boundary(hex_address, True)]
return {
kevin-deyoungster /
Last active Jul 26, 2020
(SqliteDict -> Postgres) Script to migrate an SqliteDict-initialized sqlite database to Postgres.
This script migrates data from an sqlitedict-initialized database
to postgres database with similar schema
The resulting postgres database will have schema:
* key (str)
* value (jsonb/json binary)
from psycopg2 import connect, Error
from sqlitedict import SqliteDict
kevin-deyoungster /
Created Jul 14, 2020
QGIS script to export selected features to GeoJSON (separately)
import json
layer = qgis.utils.iface.activeLayer()
for i, elem in enumerate(layer.selectedFeatures()):
attrs = elem.__geo_interface__
filename = attrs["properties"]["DISTRICT"] # change this to whatever you want to be filename
View Latex two-column with wide table
\lipsum[1-5] % To create a random first page
kevin-deyoungster /
Created Jun 29, 2019
Walk through folder and apply function on files with specific extension
This module handles crawling through folders and subfolders and applies function
on certain files
from pathlib import Path
def walk_and_apply_function(target_extension, function, folder=None):
Goes through [folder] recursively and runs function on every [target_extension] file