Exemple #1
0
    def testto_scratch(self):
        est = []
        obs = []
        arcpy.env.scratchWorkspace = arcpy.env.scratchGDB
        s = arcpy.env.scratchWorkspace

        est.append(ap.to_scratch('foo', 0))
        obs.append(ap.os.path.join(s, 'foo'))
        est.append(ap.to_scratch('foo', 1))
        obs.append(os.path.join(s, 'foo0'))
        est.append(ap.to_scratch('foo.shp', 0))
        obs.append(os.path.join(s, 'foo_shp'))
        est.append(ap.to_scratch('foo.shp', 1))
        obs.append(os.path.join(s, 'foo_shp0'))

        # not tested for file based workspaces
        arcpy.env.scratchWorkspace = arcpy.env.scratchFolder
        a = arcpy.env.scratchWorkspace
        ap.to_scratch('foo', 0) == os.path.join(s, 'foo')
        ap.to_scratch('foo', 1) == os.path.join(s, 'foo0')
        ap.to_scratch('foo.shp', 0) == os.path.join(s, 'foo_shp')
        ap.to_scratch('foo.shp', 1) == os.path.join(s, 'foo_shp0')

        eq = all([ei == oi for ei,oi in zip(est, obs)])
        self.assertTrue(eq)
Exemple #2
0
    def testto_scratch(self):
        est = []
        obs = []
        arcpy.env.scratchWorkspace = arcpy.env.scratchGDB
        s = arcpy.env.scratchWorkspace

        est.append(ap.to_scratch('foo', 0))
        obs.append(ap.os.path.join(s, 'foo'))
        est.append(ap.to_scratch('foo', 1))
        obs.append(os.path.join(s, 'foo0'))
        est.append(ap.to_scratch('foo.shp', 0))
        obs.append(os.path.join(s, 'foo_shp'))
        est.append(ap.to_scratch('foo.shp', 1))
        obs.append(os.path.join(s, 'foo_shp0'))

        # not tested for file based workspaces
        arcpy.env.scratchWorkspace = arcpy.env.scratchFolder
        a = arcpy.env.scratchWorkspace
        ap.to_scratch('foo', 0) == os.path.join(s, 'foo')
        ap.to_scratch('foo', 1) == os.path.join(s, 'foo0')
        ap.to_scratch('foo.shp', 0) == os.path.join(s, 'foo_shp')
        ap.to_scratch('foo.shp', 1) == os.path.join(s, 'foo_shp0')

        eq = all([ei == oi for ei,oi in zip(est, obs)])
        self.assertTrue(eq)
Exemple #3
0
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
tmp = ap.head(fc, 5, False, '|',  '-')

# Print some basic statistics for each column.
tmp = ap.summary(fc)
# Force lime, soil, and ffreq to be treated as categorical variables.
tmp = ap.summary(fc, ['lime', 'soil', 'ffreq'], ['CAT', 'CAT', 'CAT'])
Exemple #4
0
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
tmp = ap.head(fc, 5, False, '|', '-')

# Print some basic statistics for each column.
tmp = ap.summary(fc)
# Force lime, soil, and ffreq to be treated as categorical variables.
tmp = ap.summary(fc, ['lime', 'soil', 'ffreq'], ['CAT', 'CAT', 'CAT'])