This file contains hidden or 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 |
This file contains hidden or 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
# Compress Shapefile by reducing Text Field lengths, dropping M and Z | |
# Unfortunately .management.AlterField only works for unpopulated text fields | |
# Process: Copy Table to NumPy array, Determine max length of text fields | |
# Create blank feature with previous as template, alter text field length | |
# Copy features to new feature class in memory | |
import arcpy.management as mg | |
import numpy as np | |
def compressSHP(inSHP, outSHP): | |
fields = [f.name for f in arcpy.ListFields(inSHP) if not f.name == 'Shape'] |
This file contains hidden or 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
def write_geojson_to_records(geojson): | |
"""Will write geojson to a list of dictionaries with geomtry keys holding coordinates and storing the properties | |
to dictionaries.""" | |
gjson_data = json.loads(geojson, encoding='utf-8') | |
records = [] | |
arc_print("Geojson being read by row...") | |
for feature in gjson_data["features"]: | |
try: | |
row = {} | |
row["geometry"] = feature["geometry"] |
This file contains hidden or 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
'''Provides utility functions for encoding and decoding linestrings using the | |
Google encoded polyline algorithm. | |
''' | |
def encode_coords(coords): | |
'''Encodes a polyline using Google's polyline algorithm | |
See http://code.google.com/apis/maps/documentation/polylinealgorithm.html | |
for more information. | |
This file contains hidden or 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
# start with an excel table with two columns | |
# first row should be headers "FIELD" and "ALIAS" | |
# copy both columns to clipboard including headers | |
# use copyFieldsToClipboard to get the list | |
# optionally add a column called "RENAME" and run renameFields | |
import pandas as pd | |
def copyFieldsToClipboard(lyr): | |
fieldList = [f.name for f in arcpy.ListFields(lyr)] |
This file contains hidden or 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 | |
import pandas as pd | |
#~~~~USER INPUT PARAMETERS~~~~ | |
maxNearPoints = 20 | |
anisotropyFactor = 15 | |
searchTransv = 200 #meters | |
searchLongitud = searchTransv*anisotropyFactor #meters | |
gridSize = 3 #meters | |
invDistPower = 1 |
This file contains hidden or 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
""" invdisttree.py: inverse-distance-weighted interpolation using KDTree | |
fast, solid, local | |
https://stackoverflow.com/a/3119544 | |
""" | |
from __future__ import division | |
import numpy as np | |
from scipy.spatial import cKDTree as KDTree | |
# http://docs.scipy.org/doc/scipy/reference/spatial.html | |
__date__ = "2010-11-09 Nov" # weights, doc |
This file contains hidden or 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
' Multiple Linear Regressions in Excel | |
' This group of functions uses the Hat Matrix and | |
' Leverages to calculate the PRESS statistic | |
' A column of ones must precede your X columns (exR) | |
' https://en.wikipedia.org/wiki/PRESS_statistic | |
' https://en.wikipedia.org/wiki/Projection_matrix | |
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Function Hat(exR As Range) As Variant | |
'Returns a symmetrical array of dimensions n by n |
This file contains hidden or 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
# This script interpolates river bathymetry in an anisotropic way. | |
# Following the stream centerline, the interpolation is weighted longitudinally. | |
# This is accomplished by projecting the sinuous river to a straight line (s, n) coordinates, | |
# where s is distance downstream and n is distance left/right perpindicular to centerline. | |
# In (s, n) coordinates, the river is then compressed longitudinally, and then interpolated normally. | |
# The compression gives interpolation weight to upstream/downstream points instead of going up the bank. | |
# For best results the centerline should be smoothed, otherwise the inside bend has overlapping points. | |
# Input Excel file has three sheets, with simple X, Y, Z columns. X, Y only for centerline. | |
import pandas as pd |
This file contains hidden or 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
from http import client | |
def USGS10mElev(lat,lon): | |
usgs = client.HTTPConnection('nationalmap.gov') | |
usgs.request('GET','/epqs/pqs.php?x=%.6f&y=%.6f&units=FEET&output=xml'% (lon, lat)) | |
result = usgs.getresponse() | |
if result.status == 200: | |
xml = result.read() | |
return float(xml[xml.find(b'<Elevation>')+11:xml.find(b'</Elevation>')-1]) | |
else: return request |