Skip to content

Instantly share code, notes, and snippets.

View pmacMaps's full-sized avatar

Patrick McKinney pmacMaps

  • Commonwealth of Pennsylvania
  • Harrisburg, PA
  • 01:41 (UTC -04:00)
View GitHub Profile
@pmacMaps
pmacMaps / combine_road_component_fields_esri_arcade.js
Created March 11, 2020 17:27
An Esri Arcade expression for labeling features or map pop-ups that combines various road street name component fields into a single value.
// This is an Esri Arcade expression for labeling features or map pop-ups that combines various road street name component fields into a single value.
// It tests for empty values in the record. If the value is empty, it returns an empty string ('').
// If the value is not empty, it returns the value of the record.
// See https://developers.arcgis.com/arcade/ for more information on Arcade
// See https://www.nena.org/page/NG911GISDataModel for more information on NENA NextGen911 data model
// Example road: North Main Street
// variable to hold the contents of the label for roads
var road_label = "";
@pmacMaps
pmacMaps / esri-mapseries-alt-text-enhancement
Last active November 20, 2019 15:02
Solution to add alt text attribute to pop-ups with images for the Map Series StoryMap template. This assumes the layer with pop-up is in each web map within app
// this represents with "custom-scripts.js" file located within the "app" directory of appliation files
define(["dojo/topic"], function(topic) {
/*
* Custom Javascript to be executed while the application is initializing goes here
*/
// The application is ready
topic.subscribe("tpl-ready", function(){
/*
* Custom Javascript to be executed when the application is ready goes here
@pmacMaps
pmacMaps / esri-storymap-map-tour-alt-text-ie11.js
Created October 22, 2019 15:38
Add Alt Attribute to Images in Esri Map Tour StoryMap (Classic Series). Code is supported in IE11
require(["dojo/topic"], function(topic) {
// default alt text to apply to images
const defaultAltText = 'a view along the Yellow Breeches Creek';
// function to set alt attribute for images
function setAltText(title,img) {
// use grouped text if slide title text exists
if (title) {
// grouped text
const groupedAltText = "".concat(defaultAltText, "; map tour stop: ").concat(title);
@pmacMaps
pmacMaps / esri-storymap-map-tour-alt-text.js
Last active October 22, 2019 15:41
Add Alt Attribute to Images in Esri Map Tour StoryMap (Classic Series)
require(["dojo/topic"], function(topic) {
// default alt text to apply to images
const defaultAltText = 'a view along the Yellow Breeches Creek';
// function to set alt attribute for images
function setAltText(title,img) {
// use grouped text if slide title text exists
if (title) {
// grouped text
const groupedAltText = `${defaultAltText}; map tour stop: ${title}`;
# ---------------------------------------------------------------------------
# Name: Loop Through Layer "A" and Clip Features from Layer "B"
#
# Author: Patrick McKinney, Cumberland County GIS ([email protected] or [email protected])
#
# Created on: 6/21/2019
#
# Description: This sample script provides a template for how to loop through a layer (A) and clip features
# from another layer (B) based upon each record in layer A.
#
@pmacMaps
pmacMaps / esri-leaflet-map-service-load-test.js
Created February 1, 2019 17:05
Esri Leaflet Map Service Loaded to Map Function
// function to handle load event for map services
// See API reference at https://esri.github.io/esri-leaflet/api-reference/services/service.html#events
function processLoadEvent(service) {
// service request success event
service.on('requestsuccess', function(e) {
// set isLoaded property to true
service.options.isLoaded = true;
});
// request error event
@pmacMaps
pmacMaps / featured-image--jekyll-post-snippets.html
Last active April 19, 2020 12:49
Sample code for Jekyll Featured Image Template Blog Post
<!-- 1. Post File [2018-09-30-Sample-Post.md] -->
---
layout: post
title: A Sample Post
date: 2018-09-30
author: Mike the Blogger
description: This is the one blog post to rule them all
featured-image: my-awesome-photo.jpg
featured-image-alt: Mike the Blogger speaking at Times Square, New York City, New York
categories: Side Hustle
@pmacMaps
pmacMaps / stop_start_services.py
Last active January 17, 2023 22:10
Start or Stop an ArcGIS Server Service (ArcPy Script)
# Sample script to start/stop ArcGIS Server service
# import modules
import arcpy, os, sys, time, datetime, urllib, urllib2, json
# generate token for server
def gentoken(server, port, adminUser, adminPass, expiration=60):
# Re-usable function to get a token required for Admin changes
query_dict = {'username': adminUser,
'password': adminPass,
@pmacMaps
pmacMaps / ListBrokenDataSources.py
Created August 1, 2018 19:18
ArcPy Python script to list out broken data sources in an ArcMap document
#-------------------------------------------------------------------------------
# Name: Lesson 24 - Working With Multiple Maps In A Directory,
# Geospatial Programming
#
# Author: Patrick McKinney, Harrisburg Area Community College
#
# Created: 6/13/17
#
# Description: sample script for looping through a folder (directory)
# and listing broken data sources in each map document (.mxd)
@pmacMaps
pmacMaps / custom-tool.py
Last active July 17, 2018 14:58
Python module to use with ArcPy custom geoprocessing tools that provides an error message including system message, line number, and file of error
# this is the file where the logic for your custom tool goes
# import modules
# import errorLogger.py module
import arcpy, sys, errorLogger
# run your tool's code
try:
pass
# your code goes here
# If an error occurs running geoprocessing tool(s) capture error and write message