Skip to content

Instantly share code, notes, and snippets.

@knu2xs
knu2xs / .bowerrc
Last active August 29, 2015 13:56
Bower files for my current ideas to quickly get everything to get started.
{
"directory": "resources",
"json": "bower.json"
}
@knu2xs
knu2xs / gauge-test-watauga.js
Last active August 29, 2015 13:56
Trying to download and get gauge data
// create site object instance for watauga
var watauga = new Site('03479000');
// download the data from the USGS
watauga.downloadData();
// get the cfs output as JSON (this currently is not working)
watauga.getCfs();
@knu2xs
knu2xs / demo-cad-to-arcgis.py
Last active August 29, 2015 14:00
Scripts from my presentations at Esri's Southeast User Conference
"""
name: cadToArcgis.py
father: Joel Mccune (jmccune@esri.com)
birthdate: 01 Apr 2014 (April Fool!)
purpose: Your eternal Pythonistic enlightenment...and something about
CAD to ArcGIS conversion as well.
"""
# import modules
import arcpy
#### Python has many built-in functions
# len() - Returns the length
fc = "Railroads.shp"
print len(fc)
fields = ["OID", "Shape", "Name"]
print len(fields)
#max() - Returns the maximum value
@knu2xs
knu2xs / select_and_zoom.py
Last active October 25, 2020 15:11
Select and zoom to features in ArcMap
# import modules
import arcpy
def select_zoom(layer, sql):
"""
Select from the current map document, a feature in a layer and zoom to the specified feature.
"""
# select by attributes enforcing new selection method to clear any previous selections
SelectLayerByAttribute_management(in_layer_or_view=layer,
selection_type='NEW_SELECTION',
@knu2xs
knu2xs / noaa_ftp.py
Created May 19, 2014 15:23
Connect to the ftp server and retrieve all NOAA quantitative predictive forecast (QPF) resources for day one.
# import modules
from ftplib import FTP
import os
def get_day_one(directory_target):
"""
Retrieve zero to 30 hour precipitation forecasts
"""
# ftp url
url = 'ftp.hpc.ncep.noaa.gov'
@knu2xs
knu2xs / aw_crawl.js
Last active August 29, 2015 14:01
Trying to eventually create a comma separated list of river reaches.
// module imports
var request = require('request');
var cheerio = require('cheerio');
// variables
var url_root = "http://www.americanwhitewater.org/content/River/detail/id/";
var reach_id_start = 1;
var reach_id_end = 20;
var river_reaches = [];
@knu2xs
knu2xs / uagi_calculateViolence.py
Last active August 29, 2015 14:01
Fix data error in UAGI
'''
Name: uagi_calculateViolence.py
Purpose: In the spatial statistics chapter of UAGI, it is necessary to
create and calculate a violence score field. This script takes care
of the heavy lifting for you. It adds and populates the field for
you.
Author: Joel McCune
Created: 05 Sep 2014
'''
@knu2xs
knu2xs / get_feature_service.py
Last active August 29, 2015 14:01
Convert ArcGIS Server Definition draft from map service to feature service with editing permissions to be published on ArcGIS online
# import minidom module
import xml.dom.minidom as DOM
def get_feature_service(sddraft):
"""
Converts the default type of sddraft file from a map service to a feature service for publishing to AGOL.
Copied and adaped from http://resources.arcgis.com/en/help/main/10.1/index.html#//00s30000006q000000
:param sddraft:
:return: sddraft: modified to be a feature service
@knu2xs
knu2xs / test_bon_logins.py
Last active August 29, 2015 14:02
Test the provided credentials for teaching ARC4.
"""
name: test_bon_logins.py
author: Joel McCune (jmccune@esri.com)
date: 02 Jun 2014
purpose: This script tests all the student credentials used for an ARC4 course. The results are, by default, written
to a logfile created in the C:/Student directory. This location can be changed by providing an input for the
optional output_dir parameter when calling the test_logins function.
Please only use this as an initial preliminary test. Oddly enough, although all credentials were passing