Skip to content

Instantly share code, notes, and snippets.

View vincentsarago's full-sized avatar

Vincent Sarago vincentsarago

View GitHub Profile
@darrenwiens
darrenwiens / main.py
Created April 6, 2023 20:20
Segment anything API, segments static Mapbox Satellite Image
from fastapi import FastAPI
from pydantic import BaseModel
import torch
import torchvision
import numpy as np
from PIL import Image
import random
import requests
import base64
import io

Holy grail

Before diving too deeply into the various friction points when working with archives of earth observation data in xarray, let's look at a more optimal case from the earth systems world. In the notebook here we demonstrate how using zarr's consolidated metadata option to access the dimensional and chunk reference information, a massive dataset's dimensions and variables can be loaded extremely quickly. With this consolidated metadata available to reference chunks on disk, we can leverage xarray's dask integration to use normal xarray operations to lazily load chunks in parallel and perform our calculations using dask's blocked algorithm implementations. Gravy.

Challenges

But the earth observation story is more complicated... Not everything lives in standardized file containers and more importantly our grid coordinate systems are "all over the map" :] Here are some of the current challenges.

  1. Consolida
@iandees
iandees / README.md
Last active August 22, 2021 21:35
Download and process Bing Buildings into Census tracts.

These are my notes for taking the Microsoft US Building Footprints and splitting them into more manageable chunks based on US Census Tracts.

All of this happened on an m5.xlarge in AWS and used up about ~300GB of EBS over the course of a few hours.

  1. Make a filesystem on the EBS volume and mount it:

    sudo mkfs.xfs /dev/nvme1n1
    mount /dev/nvme1n1 /mnt
    
@perrygeo
perrygeo / gdal_install.sh
Created July 13, 2016 16:58
Install multiple gdal versions to /usr/local/gdal/
#!/bin/bash
set -ex
GDALBUILD="$(realpath `dirname $BASH_SOURCE`)/build"
GDALINST="/usr/local/gdal"
CPUS=4
GDALOPTS=" --with-webp=yes \
--with-geos=/usr/local/bin/geos-config \
--with-static-proj4=/usr/local \
@wboykinm
wboykinm / turf_and_vts.md
Last active April 15, 2024 14:57
Learnings while geoprocessing vector tiles with turf.js
@wboykinm
wboykinm / falsehoods.md
Last active February 1, 2024 15:52
Falsehoods programmers believe about addresses - by Michael Tandy

Falsehoods programmers believe about addresses

This is an anchor-linked version of the excellent, amazing original opus magnum by Michael Tandy.

An address will start with, or at least include, a building number.

Counterexample: Royal Opera House, Covent Garden, London, WC2E 9DD, United Kingdom.

When there is a building number, it will be all-numeric.

Counterexample: 1A Egmont Road, Middlesbrough, TS4 2HT

#!/usr/bin/env zsh
# ./day.sh month_number morning_day evening_day zoom_level
# Strictly alpha: for example, does not know how to handle
# month edges or unscheduled missing images.
set -eu
year=$1
@gene1wood
gene1wood / all_aws_lambda_modules_python.md
Last active April 25, 2024 03:06
AWS Lambda function to list all available Python modules for Python 2.7 3.6 and 3.7
create or replace function pointToTileFraction(float, float, integer) returns int[3] as $$
declare
lon ALIAS FOR $1;
lat ALIAS FOR $2;
z ALIAS FOR $3;
result int[];
BEGIN
result := array_append(result, floor(pow(2,z) * (lon / 360 + 0.5))::int);
result := array_append(result, floor(pow(2,z) * (0.5-0.25 *(log((1 + sin(lat*pi()/180))/(1 - sin(lat*pi()/180)))/pi())))::int);
@samuelestabrook
samuelestabrook / Qt_fix_QGIS.md
Last active August 29, 2015 14:24
Fix Qt for Homebrew QGIS install

Fix Qt for Homebrew QGIS install

Go to terminal and roll back the Qt installation through GitHub

$ brew uninstall qt
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew/8dd3478131b232553f4c0cab197f8443a0a559a6/Library/Formula/qt.rb