def testtstamp(self): est = [] est.append(len(ap.tstamp()) == len('20140216184029')) est.append(len(ap.tstamp("lr")) == len('lr20140216184045')) est.append(len(ap.tstamp("lr", "%H%M%S")) == len('lr184045')) est.append(len(ap.tstamp("lr", "%H%M%S")) == len('lr184045')) est.append(len(ap.tstamp("lr", "%H%M%S", s=('run',1))) == len('lr184527_run_1')) obs = [True, True, True, True, True] self.assertEqual(est, obs) pass
# Suppose we want to add full labels indicating landuse at points. # This can come as a table, json, or other forms. Anyhow, we would # convert it to a Python dictionary. I simply re-typed help of 'sp': # http://cran.r-project.org/web/packages/sp/sp.pdf landuse2luse = { 'Aa': 'Agriculture/unspecified', 'Ab': 'Agr/sugar beetsm', 'Ag': 'Agr/small grains', 'Ah': 'Agr/??', 'Am': 'Agr/maize', 'B': 'woods', 'Bw': 'trees in pasture', 'DEN': '??', 'Fh': 'tall fruit trees', 'Fl': 'low fruit trees', 'Fw': 'fruit trees in pasture', 'Ga': 'home gardens', 'SPO': 'sport field', 'STA': 'stable yard', 'Tv': '??', 'W': 'pasture' } # now we need to add a column for these labels ap.add_col(fc, 'luse', 'TEXT') # and update the column with landuse dictionary: # (If you're in ArcMap and fc's attribute table is open, # you will need to Reload Cache in Table Options.) ap.update_col_from_dict(fc, landuse2luse, 'luse', 'landuse') # So why didn't we use table join to do this? You could, especially if you # have Advanced license so you can use JoinFied_management. With Basic license, # it is much easier to use ap.update_col_from_dict, which is also pretty # fast on mederate-sized datasets thanks to the use of an update cursor. # Finally, make a note about this update to metadata of fc ap.meta(fc, 'APPEND', abstract='Updated at ' + ap.tstamp()) # To list all functions available in arcapi and their help: help(ap.arcapi)
'Bw': 'trees in pasture', 'DEN': '??', 'Fh': 'tall fruit trees', 'Fl': 'low fruit trees', 'Fw': 'fruit trees in pasture', 'Ga': 'home gardens', 'SPO': 'sport field', 'STA': 'stable yard', 'Tv': '??', 'W': 'pasture' } # now we need to add a column for these labels ap.add_col(fc, 'luse', 'TEXT') # and update the column with landuse dictionary: # (If you're in ArcMap and fc's attribute table is open, # you will need to Reload Cache in Table Options.) ap.update_col_from_dict(fc, landuse2luse, 'luse', 'landuse') # So why didn't we use table join to do this? # You could, especially if you have Advanced # license so you can use JoinFied_management. # With Basic license, it is much easier to use # ap.update_col_from_dict, which is also pretty # fast with its update cursor. # Finally, make a note about this update to metadata of fc ap.meta(fc, 'APPEND', abstract='Updated at ' + ap.tstamp()) # To list all functions available in arcapi and their help: help(ap)