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
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
# 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
'''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
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
# 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
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
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 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 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 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
# 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 |