Skip to content

Instantly share code, notes, and snippets.

View reyemtm's full-sized avatar
🎯
Focusing

Malcolm Meyer reyemtm

🎯
Focusing
View GitHub Profile
@reyemtm
reyemtm / slopeIx.js
Created December 16, 2023 14:13
Find the perpendicular line from a line AB to point C using Turf JS
function slopeIx(a, b, c) {
//GET POINT OF X AND Y INTERCEPT FROM POINT C AND LINE AB
const lines = turf.featureCollection([]);
const bearing1 = turf.bearing(a, b);
const slope = (b[1] - a[1]) / (b[0] - a[0]);
const point1 = [c[0], slope * (c[0] - a[0]) + a[1]];
const point2 = [(c[1] - a[1]) / slope + a[0], c[1]];
const lineArray = [a, b, point1, point2];
//NORMALIZE LINE
@reyemtm
reyemtm / esr-toner
Created October 16, 2023 11:34
esri-toner
{
"version": 8,
"sprite": "https://cdn.arcgis.com/sharing/rest/content/items/3e1a00aeae81496587988075fe529f71/resources/styles/../sprites/sprite",
"glyphs": "https://basemaps.arcgis.com/arcgis/rest/services/OpenStreetMap_v2/VectorTileServer/resources/fonts/{fontstack}/{range}.pbf",
"sources": {
"esri": {
"type": "vector",
"tiles": [
"https://basemaps.arcgis.com/arcgis/rest/services/OpenStreetMap_v2/VectorTileServer/tile/{z}/{y}/{x}.pbf"
],
@reyemtm
reyemtm / quotes.json
Last active April 28, 2023 12:39
Quotes
{
"quotes": [
{
"quote": "Better a diamond with a flaw than a pebble without.",
"author": "Confucius"
},
{
"quote": "But one of the core rules to make the Zettelkasten work for you is to use your own words, instead of just copying and pasting something you believe is useful or insightful. This forces you to at least create a different version of it, your own version.",
"author": ""
},
@reyemtm
reyemtm / esri-toner.json
Created June 6, 2022 11:14
Esri OSM Toner GL Style
{
"version": 8,
"sprite": "https://cdn.arcgis.com/sharing/rest/content/items/3e1a00aeae81496587988075fe529f71/resources/styles/../sprites/sprite",
"glyphs": "https://basemaps.arcgis.com/arcgis/rest/services/OpenStreetMap_v2/VectorTileServer/resources/fonts/{fontstack}/{range}.pbf",
"sources": {
"esri": {
"type": "vector",
"tiles": ["https://basemaps.arcgis.com/arcgis/rest/services/OpenStreetMap_v2/VectorTileServer/tile/{z}/{y}/{x}.pbf"],
"maxzoom": 22,
"attribution": "Map data <a href='https://www.openstreetmap.org/copyright' target='_blank'>©OpenStreetMap contributors</a>, Microsoft, Esri Community Maps contributors, <a href='https://www.arcgis.com/home/group.html?id=5e0d56e27d7e4a68955d399ca96c41cb#overview' target='_blank'>Map Style by Esri</a> | <a href='https://stamen.com/contact/' target='_blank'>Stamen</a>"
@reyemtm
reyemtm / syncFeatureWithTable.py
Created April 7, 2022 18:07
Esri syncFeatureWithTable.py
# ---------------------------------------------------------------------------
# MuniLink Utilities > GIS sync
# ---------------------------------------------------------------------------
# Created by Malcolm Meyer 03/29/2022
# Description:
# This script copies view tables from the MuniLink database to the GIS database
# --or-- it may create dictionaries instead
# Then these GIS Database tables (or dictionaries) are used to sync data to various GIS layers
# Which then syncs data over to Cartegraph in the morning via AGOL <> Cartegraph sync
# ---------------------------------------------------------------------------
@reyemtm
reyemtm / mglSelectFeatures.js
Created July 8, 2021 13:16
Select Features in Mapbox GL JS
import { booleanContains, booleanOverlap, booleanWithin, flatten, bbox, featureCollection, envelope, circle } from "@turf/turf"
/**
* This function takes a polygon or point and selects other features in the map that intersect this feature. It returns the features as well as an array contaiing a list of unique ids for these features based on the properties field provided.
* @param {object} map Mapbox map object
* @param {object} selectingFeatures GeoJSON FeatureCollection
* @param {Array} layers Array of Mapbox layers to query
* @param {string} field Field used to filter the features
* @param {Function} filter Function used on each feature to optionally filter out features.
* @example
const fs = require('fs'),
path = require('path');
const sharp = require('sharp');
const ora = require("ora");
if (process.argv.length < 3) {
console.log("A relative or full directory path is required.")
return
}
@reyemtm
reyemtm / convertIMGtoWEBP.js
Created January 11, 2021 13:56
Node PNG or JPG to WebP
const fs = require('fs'),
path = require('path');
const sharp = require('sharp');
const ora = require("ora");
if (process.argv.length < 3) {
console.log("A relative or full directory path is required.")
return
}
@reyemtm
reyemtm / combine-shp.js
Last active March 12, 2020 13:51
mergeNamedShapefilesToGeoJSON
//MAP THROUGH ALL FILES TO GET AN ARRAY OF SHAPEFILES TO CONVERT
//MAP THROUGH EACH FILE TO GET FEATURES AND PUSH TO MASTER, ADD FILENAME AS TYPE AND COLLECT FIELDS
//MAP THROUGH MASTER AND ADD MISSING FIELDS
var fs = require("fs");
var shapefile = require("shapefile");
var converted = {
type: "FeatureCollection",
features: []
@reyemtm
reyemtm / index.html
Last active June 12, 2019 18:07
Turf Trace
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Trace Network</title>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.51.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.51.0/mapbox-gl.css' rel='stylesheet' />