Posts

Showing posts with the label Python

Python Script for Roman Numerals

Here a python script for Roman Numerals: romanNumerals = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} def getRomanNumerals(value):     string = value.upper()     total = 0     while string:         if len(string) == 1 or romanNumerals[string[0]] >= romanNumerals[string[1]]:             total += romanNumerals[string[0]]             string = string[1:]         else:             total += romanNumerals[string[1]] - romanNumerals[string[0]]             string = string[2:]     return total getRomanNumerals(!FieldName!) Check out my other blog post about Calculate Sequential Numbers .

Calculate Station from Decimal

Here's a little python function to calculate the stationing text from a decimal number def calculate(value):     valDecimal =  value.split('.')[1][:2]     if len(valDecimal) == 1:         valDecimal = valDecimal + "0"     varLast = value.split('.')[0][-2:]     varFirst = value.split('.')[0][:-2]     return varFirst + "+" + varLast + "." + valDecimal calculate( str(!BEGIN_STATION!) ) Input - 5622.068 Output - 56+22.06

Convert from Degrees Minutes Seconds to Decimal Degrees in Python

def latDD(x):   x = re.findall("\d+", x)   print x   D = int(x[0])   M = int(x[1])   S = float(x[2] + "." + x[3])   DD = D + float(M)/60 + float(S)/3600   return DD print latDD("40°36'34.81") Happy GISing! Lindsy Hales Bentley