Posts

Showing posts with the label Utah

Rename Sub Folders in A Directory With Python

Here's a little bit of code that renames sub folders in a directory with python. import os import os.path for (dirpath, dirnames, filenames) in os.walk(r'O:\!2016\your folder path here):     for idx in range(len(dirnames)):         print(dirnames[idx])         newname = dirnames[idx].split(' ')[0].upper() + " " + dirnames[idx].split(' ')[1].upper()         os.rename(os.path.join(dirpath, dirnames[idx]), os.path.join(dirpath, newname))         dirnames[idx] = newname

Harvey

My friend Harvey is retiring. I learned one of the most valuable GIS lessons of my career so far from Harvey. I met Harvey about a year into my GIS career.  Harvey was a cowboy fireman with the most impressive mustache.  He was in the office on light duty following a surgery. We were paired up to work on a few projects together, creating spreadsheets and maps. Harvey has bad eye sight.  The mapbook I made for the fire department had 27 pages covering the city.  But Harvey couldn't see it and would throw the mapbook at someone else to look at it while on their way to a call.  For Christmas later that year, we made Harvey his own special mapbook, with 108 pages covering the city.  He chuckled.  And used it. To this day, every map I make, I make with Harvey in mind.  Harvey is an old soul that doesn't like computers.  He has no use for complex maps.  While GIS is complex and ever-growing, I try to make every map a map that Ha...

Sequential Numbers

In ArcMap, here is how you can calculate sequential numbers using Field Calculator. Set field calculate to python. Paste this in pre logic script: rec=0 def autoIncrement():  global rec  pStart = 1   pInterval = 1  if (rec == 0):    rec = pStart   else:    rec += pInterval   return rec Paste this in second box autoIncrement() Check out one of my other posts about how to Convert from Degrees Minutes Seconds to Decimal Degrees in Python here . Happy GISing! Lindsy Hales Bentley

How to pull numbers out of a string

Here’s a little function to pull numbers out of a string. import re def calculate(value):   newVal = re.sub("[^0-9]", "", value)   if newVal == "":     return 0   elif newVal is None:     return 0   else:     return newVal calculate( !Size! ) Happy GISing! Lindsy Hales Bentley

ESRI GIS Model Builder

Image
Who here loves Model Builder? Well, if you haven't had a reason to use it before, let's chat about it's benefits.  Prior to my working at an engineering firm, I never had a reason to use it.  There wasn't anything that I did on a regular basis that called for it.  I took all of the classes, read all of the books, and I just didn't get why it was useful. Then, I was asked to convert utilities for a project.  Not just once, but on a weekly basis.  Start to finish, it took me two weeks to convert and clean up the utilities from CAD on that beastly project.  Two.  VERY. PAINFUL. Weeks.  *Bang head against desk here.* This meant the utilities were never up to date in the project map.  After two months of figuring out the kinks in the conversion process, I was challenged to create a model of this process.  It looked something like this: Yes I'm OCD, and everything has to line up pretty. My first model.  I had my doubts ...