def testnames(self): est = map(str, tuple(ap.names(self.t_fc))) obs = ('OBJECTID','Shape','ScaleRank','LabelRank','FeatureCla', 'SOVEREIGNT','SOV_A3','ADM0_DIF','LEVEL','TYPE','ADMIN', 'ADM0_A3','GEOU_DIF','GEOUNIT','GU_A3','SU_DIF','SUBUNIT', 'SU_A3','NAME','ABBREV','POSTAL','NAME_FORMA','TERR_', 'NAME_SORT','MAP_COLOR','POP_EST','GDP_MD_EST','FIPS_10_', 'ISO_A2','ISO_A3','ISO_N3','Shape_Length','Shape_Area') self.assertEqual(tuple(est), obs) pass
# hard drive like so: url= 'https://raw.github.com/filipkral/meuse/master/meuse.txt' text = os.path.join(arcpy.env.scratchFolder, 'meuse.txt') import urllib2 ur = urllib2.urlopen(url) with open(text, 'w') as tx: tx.write(ur.read()) ur.close() # We have our data in a text file, which we need to import into ArcGIS native # format. We strongly recommend Esri File Geodatabase. # ap has short name tviw for arcpy.management.CreateTableView, # flyr and rlyr for CreateFeatureLayer and CreateRasterLayer. tb = ap.tviw(text, "tb") # check that the names and data types are what you would expect ap.names(tb) ap.types(tb) # or like this: zip(ap.names(tb), ap.types(tb)) # It is point data so let's convert it to a point feature class. # Store it as a point feature class called 'dta' in our base.gdb. fc = ap.to_points(tb, ap.to_scratch('dta'), 'x', 'y', 28992) tmp = ap.head(fc) # We don't need the table view of text any more so get rid of it. ap.dlt(tb) # And we don't need the text file itself either so get rid of it. ap.dlt(text) # Print first 10 records using default settings (columns as rows) tmp = ap.head(fc) # now print 5 rows as a formatted table, print '-' for geometries
# and save it as a text file onto your hard drive like so: url = 'https://raw.github.com/filipkral/meuse/master/meuse.txt' text = os.path.join(arcpy.env.scratchFolder, 'meuse.txt') import urllib2 ur = urllib2.urlopen(url) with open(text, 'w') as tx: tx.write(ur.read()) ur.close() # We have our data in a text file, which we need to import # into ArcGIS native format, ideally Esri File Geodatabase. # ap has short name tviw for arcpy.management.CreateTableView, # flyr and rlyr for CreateFeatureLayer and CreateRasterLayer. tb = ap.tviw(text, "tb") # check that the names and data types are what you would expect ap.names(tb) ap.types(tb) # or maybe: zip(ap.names(tb), ap.types(tb)) # It is point data so let's convert it to a point feature class. # Store it as a point feature class called 'dta' in our base.gdb. fc = ap.to_points(tb, ap.to_scratch('dta'), 'x', 'y', 28992) tmp = ap.head(fc) # We don't need the table view of text any more so get rid of it. ap.dlt(tb) # And we don't need the text file itself either so get rid of it. ap.dlt(text) # Print first 10 records using default settings (columns as rows) tmp = ap.head(fc) # now print 5 rows as a formatted table, print '-' for geometries