Skip to content

Instantly share code, notes, and snippets.

View bgpierc's full-sized avatar

Ben Pierce bgpierc

View GitHub Profile
@bgpierc
bgpierc / delentropy.py
Created March 23, 2023 17:03
Delentropy function
# condensed version of Larkin's delentropy modification from
# https://gist.github.com/mxmlnkn/5a225478bc576044b035ad4a45c54f73
import numpy as np
def delentropy(image):
# Using a 2x2 difference kernel [[-1,+1],[-1,+1]] results in artifacts!
# In tests the deldensity seemed to follow a diagonal because of the
# assymetry introduced by the backward/forward difference
@bgpierc
bgpierc / dumpDB.py
Created April 14, 2022 20:07
Write a table from MySQL to a sqllite local copy, stream data by chunk to use less RAM
# -*- coding: utf-8 -*-
import pandas as pd
import sqlalchemy
def dump_table_to_sqllite(srcEngine, srcTable, dest_path,
chunksize = 20):
"""Dump a table from a source DB to a sqllite DB. Useful to cache often-used-data locally.
Parameters
----------
from shapely.ops import cascaded_union, polygonize
from scipy.spatial import Delaunay
import numpy as np
import math
import shapely.geometry as geometry
import matplotlib.pyplot as plt
#Source: https://sgillies.net/2012/10/13/the-fading-shape-of-alpha.html
class ConcaveHull():