Skip to content

Instantly share code, notes, and snippets.

View nickrsan's full-sized avatar

Nick Santos nickrsan

View GitHub Profile
@nickrsan
nickrsan / convert_mxd_to_aprx.py
Last active October 26, 2019 22:11
Converts all ArcMap documents (.mxd) in the script's folder into ArcGIS Pro Projects - requires amaptor (available via pip and at https://github.com/ucd-cws/amaptor). Has infrastructure to convert everything in a folder into the same project, but would need some retooling for it. Must be run from an ArcGIS Pro python environmental w/amaptor inst…
import os
import amaptor
base_folder = os.path.split(os.path.abspath(__file__))[0]
def make_project(item, base_folder=base_folder, skip_items=()):
"""
Makes the .mxd in item into an ArcGIS Pro project in the same folder with the same name
:param item: a full path to an ArcMap Document
@nickrsan
nickrsan / clone_hyperv_vm.ps1
Last active January 5, 2021 21:59
Clone Hyper-V VM to same server
$ProductionVMName = "DAP_Production"
$StagingVMName = "DAP_Staging"
$ExportFolder = "C:/HyperVExports" # I created a folder that removed all permissions for users - could add anyone with hyper-v permissions to a group with read/write here, along with System
$ExportToFolder = "$ExportFolder/$ProductionVMName/"
$ImportToFolder = "$ExportFolder/$StagingVMName/"
# caution, deletes existing exports in the next block. The try/catch doesn't work as intended. It was supposed to abandon it if it can't find the staging VMs, but proceeds through each step. Needs some work there.
try{
Get-VM -Name $StagingVMName # (not true, but this was the design): this will throw an exception if it doesn't exist, so the following lines in this block won't run
Stop-VM -Name $StagingVMName -TurnOff # Turn of the VM forcibly - it's fine if it gets corrupted - we're about to destroy it
@nickrsan
nickrsan / gcloud_storage_download.py
Created September 2, 2022 20:49
Download Items from Public Google Cloud Storage Bucket
import requests
import re
from pathlib import Path
def get_public_export_urls(bucket_name, prefix=""):
"""
Downloads items from a *public* Google Storage bucket without using a GCloud login. Filters only to files
with the specified prefix
:param bucket_name:
:param prefix: A prefix to use to filter items in the bucket - only URLs where the path matches this prefix will be returned - defaults to all files
@nickrsan
nickrsan / geopandas_in_the_browser.html
Last active June 1, 2023 12:51
A simple bit of code that uses PyScript and Piodide (under the hood) to run geopandas code in the browser. Not super interesting as is, but is a great starting point for further analysis and demos
<html>
<head>
<title>Mapping with PyScript</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
</head>
<body>
<py-config>