Skip to content

Instantly share code, notes, and snippets.

@knu2xs
knu2xs / 01-filter-poi.ipynb
Created June 29, 2020 22:21
Find Safegraph POI using category and area of interest
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@knu2xs
knu2xs / databricks_conda_install.py
Created April 7, 2020 18:49
Help when setting up DataBricks cluster
dbutils.fs.put("dbfs:/home/scripts/conda_install.sh", "conda install -c esri -c conda-forge arcgis h3-py -y", True)
@knu2xs
knu2xs / create_mask.py
Created February 22, 2020 00:40
Create polygon for masking an area of interest.
import pathlib
import arcpy
from arcgis.geometry import Geometry
def create_mask_feature_class(area_of_interest:[arcpy._mp.Layer, pathlib.Path, str],
output_mask_feature_class:[str, pathlib.Path]) -> pathlib.Path:
"""Create a polygon covering the full extent of the globe, and punch out the area of interest polygons."""
# if path objects, convert to strings
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@knu2xs
knu2xs / set_environ.py
Created December 16, 2019 14:39
Python Set User Environment Variable in Windows
import os
key = 'SOME_KEY'
val = 'someValue'
os.system(f'setx {key} {val}')
@knu2xs
knu2xs / python_function_timeout.py
Created August 5, 2019 19:11
python_function_timeout.py
from multiprocessing import Process
import time
def do_actions():
"""
Function that should timeout after 5 seconds. It simply prints a number and waits 1 second.
:return:
"""
i = 0
while True:
@knu2xs
knu2xs / 01_tapestry_summary.ipynb
Last active July 25, 2019 00:41
Summarize Tapestry Using Jupiter Notebooks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@knu2xs
knu2xs / get_dataframe.py
Last active June 28, 2023 11:46
Automatically cast a variety of inputs by introspectively detecting the data type and converting to a Spatially Enabled Dataframe
from arcgis.features import GeoAccessor, FeatureLayer
from arcgis.geometry import Geometry
from arcgis.gis import GIS
import pandas as pd
import os
import re
def get_dataframe(in_features, gis=None):
"""

GeoAI DSVM SetUp

  • Create a resource
  • Search for GeoAI
  • Second option GeoAI Data Science VM from Microsoft
  • Once launched (~20 min), get IP address and connect using RDP (port 3389)

On Machine via RDP

  • Authorize Pro
    • Open Pro
  • login to Portal with username authorized to use ArcGIS Pro
@knu2xs
knu2xs / add_channels.cmd
Last active October 30, 2020 21:48
Create my default ArcGIS Python API environment following either installing or updating ArcGIS Pro
REM Must be run as Administrator due to the commands modfying a file in the "C:\Program Files" directory
REM Sets up channels in the "C:\Program Files\ArcGIS\Pro\bin\Python\.condarc" file
REM This is required so ArcGIS Pro will recognize the packages we are adding
CALL conda config --add channels conda-forge
CALL conda config --add channels esri
CALL conda config --add channels knu2xs