Skip to content

Instantly share code, notes, and snippets.

AGO

eeker_XM

Outline

  • What is a map?
  • How are maps made? (GIS)
  • Show them some cool web maps!
  • Mention the atlas!
@GISmd
GISmd / Python Packages included with ArcGIS Versions.md
Last active March 23, 2020 18:03
A simple table showing if and what versions of Pandas, Numpy, and Pip come with what versions of ArcGIS Desktop (10.1 - 10.7.1)
ArcGIS Version Pandas Numpy Pip
10.7.1 0.18.1 1.9.3 18.1
10.5 0.18.1 1.9.3 9.0.1
10.4.1 0.16.1 1.9.2 7.0.1
10.3 x 1.7.1 x
10.2 x 1.6.1 x
10.1 x 1.6.1 x
@GISmd
GISmd / renamebrains.py
Last active February 20, 2018 16:21
A little script that attempts to fix the awful naming scheme of the Brains On! podcast.
'''A little script that attempts to fix the awful naming scheme of the Brains
On! podcast.'''
import os
import glob
import eyed3
import re
def new_name(filename, mp3_date, title):
"""Gives a new filename starting with the eyed3 date and then the title
@GISmd
GISmd / findfile.py
Last active October 30, 2017 20:29
Should return a list of files that end in a specified extension.
def find_file_by_type(file_extension, directory=''):
if directory == '':
root = Tkinter.Tk()
directory = tkFileDialog.askdirectory(parent = root, initialdir = "/", title = 'Please Select a Directory')
root.withdraw()
os.chdir(directory)
targetfiles = []
for root, dirs, filenames in os.walk(directory):
for name in filenames:
if os.path.splitext(name)[1] == file_extension:
def addraster_list_to_mosaicdataset(rasterlist, mosaic_dataset_path):
"""Use this function to add a list of rasters to a mosaic dataset
Parameters:
rasterlist : list
List containing the paths to the rasters to be added to the mosaic
dataset
mosaic_dataset_path : str
String of the path to the mosaic dataset to which the rasters
will be added
@GISmd
GISmd / summarize.md
Last active February 28, 2017 21:20

Have:

ID flag
1 r
1 a
2
2
3 a
3
@GISmd
GISmd / iterativeclip.py
Last active December 2, 2016 06:13
A quick and dirty arcpy function that will iterate by features of a feature class and clip a target feature class; produces many output files
"""Needs some work. Needs error handling (empty outputs especially) and better
output naming logic.
"""
import arcpy, os
source_polys = r'path to shapefile to be clipped here'
clip_polys = r'path to shapefile whose features will be used for the clipping here'
def iterclipbyfeatures(source_polys, clip_polys, clip_id='FID',
output_prefix='', output_suffix=''):
@GISmd
GISmd / dictlists.py
Last active June 23, 2016 20:59
Functions for writing and reading dictionaries of lists to and from a CSV file.
def write_dict_to_csv(dictionary, filename):
"""Write a dictionary of lists to a CSV file with the keys as the column
heading. Will work with lists of unequal length."""
with open(filename, 'w') as myfile:
myfile.write(','.join(dictionary.keys())) # write header
for line in itertools.izip_longest(*dictionary.values(), fillvalue=''):
myfile.write('\n' + ','.join(line))
print "Created file: " + os.getcwd() + '\\' + filename
def read_dict_from_csv(filename):
@GISmd
GISmd / log.py
Last active May 25, 2016 18:40
Return logger with formatted streamhandler and filehandler
import logging
def setup_custom_logger(name):
formatter = logging.Formatter(fmt='%(asctime)s-%(levelname)s-%(module)s-%(funcName)s-%(lineno)d-%(message)s')
sthandler = logging.StreamHandler()
sthandler.setFormatter(formatter)
flhandler = logging.FileHandler('depmorph.log')
flhandler.setFormatter(formatter)
logger = logging.getLogger(name)
@GISmd
GISmd / findmissing.py
Last active June 13, 2016 20:33
Finding missing elements between two lists using collections module
import collections
def findmissing(expectedlist, foundlist):
"""Compare two lists and output lists of items that are not included"""
expected = collections.Counter(expectedlist)
found = collections.Counter(foundlist)
not_in_found = list((found - expected).elements())
not_in_expected = list((expected - found).elements())
return not_in_expected, not_in_found