Skip to content

Instantly share code, notes, and snippets.

@GMoncrieff
GMoncrieff / how_i_work.md
Last active April 27, 2024 05:45
How I do ML with geospatial data

How I do machine learning with geospatial data

I have a couple of AI/ML projects related to mapping things, often conservation related, with remote sensing data. Some details and packages will vary, but the process below describes how I generally approach these types of problems. Some of these tools I have only touched briefly, but I like them, and this is more an outline of how I would like to approach a new project than a retrospective look at my previous work.

We use AWS, so it makes sense to use datasets and services that are already hosted on AWS. The data discovery and loading part of this process would look somewhat different if we were using Azure and Planetary Computer, and very different if we were using GCP and Earth Engine.

Compute

All of my analysis will be done using python on an AWS VM in the same region as my data on S3, Probably using VSCode on Sagemaker or [JupyterLab](https://docs.aws.amazo

@MartinMuzatko
MartinMuzatko / example.js
Created January 20, 2017 15:14
GET Params in JS as Object
// location.search = '?a=b&c=d&limit=20'
var get = new Map(location.search.substr(1).split('&').map((pair)=>{return pair.split('=')}))
// get = {a:'b', c:'d', limit: 20}
var webpack = require('webpack')
var ExtractTextPlugin = require("extract-text-webpack-plugin")
var path = require('path');
module.exports = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, ''), // string
filename: "[name].js", // string
function rot(text, amount=13) {
return text.split('').map(letter=>{return String.fromCharCode(((letter.charCodeAt(0)-97+amount) % 25) + 97)}).join('')
}
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
@MartinMuzatko
MartinMuzatko / truthtable.js
Last active April 27, 2024 05:42
Truth Table
// usage : truthTable((a,b)=>a&&b, 2)
// 0,0 - 0
// 0,1 - 0
// 1,0 - 0
// 1,1 - 1
function truthTable(question, argcount) {
var combinations = binaryCombos(argcount)
for (var combination in combinations) {
combination = combinations[combination].reverse()
@MartinMuzatko
MartinMuzatko / jsonactions.vm
Created June 21, 2017 08:21
REST API with Velocity
#if( $url.query )
## Only execute when there is a query called action=json. This is our API route more or less.
## For example: localhost:8090/?action=json.getBlogPosts&pages=Test1|||Test2
## This will execute the getBlogPosts Macro with "pages" as parameter
#if( $url.query.indexOf('action=json.') != -1 )
#set( $actionIdentifier = 'action=json.' )
#if( $url.query.indexOf('&') != -1 )
#set( $action = $url.query.substring($actionIdentifier.length(),$url.query.indexOf('&')))
#set( $i = "$actionIdentifier$action" )
#set( $l = $i.length() + 1 )
<script>
var versions = [
#foreach ($v in $versions.available)
"$v.name",
#end
]
var x = versions.reverse().reduce(function(acc, item, index, items){
if (acc) {
return acc
@MartinMuzatko
MartinMuzatko / page.vm
Last active April 27, 2024 05:42
Relink unresolved versioned page
## place somewhere at the bottom before </body> - doesn't matter
<script>
window.spaceKey = '$repository.key'
</script>
@MartinMuzatko
MartinMuzatko / beautify-sql-schema.js
Last active April 27, 2024 05:41
Create SQLITE schema and format it
const sqlFormatter = require('sql-formatter')
const promisify = require('promisify-node')
const fs = promisify('fs')
const path = require('path')
const INDENT = '\t'
const SCHEMAFILE = path.resolve(__dirname, 'schema.sql')
(async () => {
try {