This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_search = LAMBDA(txt, searchtext, [case_sensitive], | |
// Test the inputs for errors so that we can distinguish | |
// the error that comes from FIND/SEARCH as meaning "not-found". | |
IFS( | |
ISERROR(txt), | |
txt, | |
ISERROR(searchtext), | |
searchtext, | |
ISERROR(case_sensitive), | |
case_sensitive, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Name: Show Moon Phase Emoji (MOONPHASE) | |
Description: Returns a lunar phase character closest matching to any Excel Date/Time value. | |
If you calculate for daily values at midnight, the lunar cycle will be the same for every 3 or 4 days (3.691 days). | |
🌑🌒🌓🌔🌕🌖🌗🌘 | |
*/ | |
MOONPHASE = LAMBDA(datetime,LET( | |
phase,MOD(ROUND(MOD(datetime,29.5275)/3.691,0)-2,8)+1, | |
UNICHAR(127760+phase))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aalii | |
aargh | |
aarti | |
abaca | |
abaci | |
aback | |
abacs | |
abaft | |
abaka | |
abamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Muskingum(timeSeries As Range, _ | |
K As Double, X As Double, _ | |
Optional Reaches As Integer = 1) As Variant | |
'Muskingum routing in Excel | |
'Returns a column array the same length as timeSeries (use array formula or spill) | |
'K (travel time) is in same units as the time step of the input timeSeries | |
'X must be between 0 and 0.5 | |
'Reaches will be automatically adjusted to avoid negative coefficients if K is < 1 / (2*(1-X)) or K > 1/2X | |
Dim Coeffs(1 To 5) As Double |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function interp(X As Double, xRange As Range, yRange As Range) As Double | |
ascending = xRange.Cells(1) < xRange.Cells(2) | |
With WorksheetFunction | |
If ascending Then i = .Match(X, xRange) Else i = .Match(X, xRange, -1) | |
Set x1x2 = Range(xRange.Cells(i), xRange.Cells(i + 1)) | |
Set y1y2 = Range(yRange.Cells(i), yRange.Cells(i + 1)) | |
interp = X * .Slope(y1y2, x1x2) + .Intercept(y1y2, x1x2) | |
End With | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove duplicate vertices from lines | |
# A point is considered duplicate if it has the same XY coordinates within a tolerance (precision) | |
# The precision is an integer number of decimal places | |
# for X,Y in lat, long, 5 decimals is 1.1 meters and 6 is 11 cm | |
def removeDupeVertices(feature, precision): | |
fields = ['SHAPE@'] + [f.name for f in arcpy.ListFields(feature)] | |
sr = arcpy.Describe(feature).SpatialReference | |
upd = arcpy.da.UpdateCursor(feature,fields) | |
orphanList = [] | |
for row in upd: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Objective: A system capable of encoding geographic points, and polylines in ASCII characters | |
# Obviously Google and geohash have similar algorithms, but with limited precision | |
# | |
# A 24-bit integer can store binary integer values up to 16,777,215 | |
# Using PEM format, 24 bits can be represented as 4 base-64 characters with the alphabet: | |
# ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ | |
# A polyline can be represented by a string of characters, | |
# where each 8 characters is a longitude/latitude location | |
# For maximum flexibility, a polyline or point string is prefixed with three characters | |
# The first two characters specifies the origin - the lower left corner of a MGRS GZD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def GIStable2Clipboard(inTable, exportFields="all"): | |
desc = arcpy.Describe(inTable) | |
if exportFields =="all": | |
exportFields = [f.name for f in arcpy.ListFields(inTable) if not f.name == desc.shapeFieldName] | |
aliases = [f.aliasName for f in arcpy.ListFields(inTable) if not f.name == desc.shapeFieldName] | |
pd.DataFrame.from_records(arcpy.da.TableToNumPyArray(inTable,exportFields), | |
index=desc.OIDFieldName, columns=aliases).to_clipboard() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.interpolate import RectBivariateSpline as Spline | |
import pygeodesy as geo | |
from pygeodesy.ellipsoidalVincenty import LatLon | |
class Geoid12B(): #NAD 83 Ellipsoid | |
# https://www.ngs.noaa.gov/GEOID/GEOID12B/GEOID12B_CONUS.shtml | |
# Download a Geoid Grid in little endian binary format ('g2012bu5.bin') | |
def __init__(self, leBinFile): | |
glamn, glomn, dla, dlo = np.fromfile(leBinFile,'<f8',4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub CalcLength() | |
'Subroutine calculates the distance of straight line or "scribble" line | |
'It has not been tested in any other Office software, but it should work with minor modification | |
'By Rob Sherrick, 4/12/2018 | |
Dim dpi As Integer | |
dpi = Application.InchesToPoints(1) | |
Length = 0 | |
A = 1 | |
On Error Resume Next |
NewerOlder