Skip to content

Instantly share code, notes, and snippets.

View Dan-Patterson's full-sized avatar

Dan Patterson Dan-Patterson

View GitHub Profile
# -*- coding: utf-8 -*-
r"""
---------
CondaPkgs
---------
----
Script :
CondaPkgs.py
@Dan-Patterson
Dan-Patterson / winding_crossing_numbers.py
Created February 17, 2020 06:02
winding, crossing number for point in polygon. python and numpy implementation for reference
# -*- coding: utf-8 -*-
r"""
Author :
Dan_Patterson@carleton.ca
Notes
-----
For a faster implementation see npgeom and npg_pip.py. the np_wn uses
numpy to speed up substantially the `pip` analysis.
@Dan-Patterson
Dan-Patterson / svg_npGeom.py
Last active January 21, 2020 01:35
svg display for numpy geometries
# -*- coding: utf-8 -*-
r"""
-----------
svg_npGeom.py
-----------
Author :
Dan_Patterson@carleton.ca
`<https://github.com/Dan-Patterson>`_.
# -*- coding: UTF-8 -*-
"""
========
vincenty
========
Script : vincenty.py
Author : Dan.Patterson@carleton.ca
@Dan-Patterson
Dan-Patterson / e_leng.py
Last active February 13, 2019 04:40
Length/distance calculations using einsum and numpy
# -*- coding: utf-8 -*-
import numpy as np
def e_leng(a, close=False):
"""Length/distance between points in an array using einsum
Parameters
----------
preprocessing :
use `_view_`, `_new_view_` or `_reshape_` with structured/recarrays
@Dan-Patterson
Dan-Patterson / e_dist.py
Last active November 2, 2021 18:07
Euclidean distance in n-dimensions using einsum
import numpy as np
def e_dist(a, b, metric='euclidean'):
"""Distance calculation for 1D, 2D and 3D points using einsum
preprocessing :
use `_view_`, `_new_view_` or `_reshape_` with structured/recarrays
Parameters
----------
@Dan-Patterson
Dan-Patterson / excel_np.py
Last active November 19, 2018 04:12
This can be used to convert excel files to numpy structured or record arrays.
# see https://community.esri.com/blogs/dan_patterson/2018/11/18/excel-arrays-tables-in-arcgis-pro for
# more information and descriptions
import numpy as np
def excel_np(path, sheet_num=0):
"""Read excel files to numpy structured/record arrays. Your spreadsheet
must adhere to simple rules::
- first row must contain the field names for the output array
- no blank rows or columns, basically, no fluff or formatting
- if you have nodata values, put them in, since blank cells will be
@Dan-Patterson
Dan-Patterson / comp_info.txt
Last active August 15, 2018 23:09
computer info
def comp_info():
"""Return information for the computer and python version
comp_info() # to use...
"""
import platform
winv = platform.platform()
py_ver = platform.python_version()
plat = platform.architecture()
proc = platform.processor()
p_node = platform._node()
@Dan-Patterson
Dan-Patterson / crosstab_2016_06_25.py
Created June 26, 2016 17:54
crosstab_2016_06_25.py
# -*- coding: UTF-8 -*-
"""
:Script: crosstab.py
:Author: Dan.Patterson@carleton.ca
:Modified: 2016- -
:Purpose:
:
:Notes:
:
:References
@Dan-Patterson
Dan-Patterson / sparse_window_demo_2016_05_03.py
Created May 5, 2016 06:47
sparse_window_demo_2016_05_03.py
"""
Script: sparse_window_demo.py
Author: Dan.Patterson@carleton.ca
Modified: 2016_05_03
Purpose:
- Conversion of point data to raster
- To produce a moving window equivalent to find the cells that are
surrounded by a particular value
References:
- http://desktop.arcgis.com/en/arcmap/latest/tools/conversion-toolbox/