Skip to content

Instantly share code, notes, and snippets.

@DakaiZhou
DakaiZhou / string_agg.sql
Last active December 14, 2021 12:54
sql_tricks1
SELECT company, STRING_AGG(employee, ', ') AS employee
FROM your_table
GROUP BY company;
@DakaiZhou
DakaiZhou / random_location_2.py
Last active November 1, 2021 09:56
medium random location
def generate_random_location_within_ROI(num_pt, polygon):
"""
Generate num_pt random location coordinates .
:param num_pt INT number of random location coordinates
:param polygon geopandas.geoseries.GeoSeries the polygon of the region
:return x, y lists of location coordinates, longetude and latitude
"""
# define boundaries
bounds_all = polygon.bounds
@DakaiZhou
DakaiZhou / random_location_1.py
Last active October 28, 2021 15:47
medium random location
import geopandas as gpd
import pandas as pd
import numpy as np
from shapely.geometry import Polygon
from shapely.geometry import box
import matplotlib.patches as patches
import random
from shapely.geometry import Point
import matplotlib.pyplot as plt
from copy import copy