#!coding: utf-8
import numpy as np
import arcpy
def addGRB2ToMosaic(grb2name):
print "start add raster"
mygdb = u'/mosaic/mosaic/gdbs/data.gdb/image'
mdname = mygdb # u"Z:\\gdbs\\data.gdb\\image"
rastype = "Raster Dataset"
inpath = u"/mosaic/mosaic/grb2/{0}".format(grb2name)
print(inpath)
updatecs = "UPDATE_CELL_SIZES"
updatebnd = "UPDATE_BOUNDARY"
updateovr = "NO_OVERVIEWS"
maxlevel = "2"
maxcs = ""
maxdim = ""
spatialref = ""
inputdatafilter = "*.GRB2"
subfolder = "NO_SUBFOLDERS"
duplicate = "OVERWRITE_DUPLICATES"
buildpy = "NO_PYRAMIDS"
calcstats = "CALCULATE_STATISTICS"
buildthumb = "NO_THUMBNAILS"
comments = "Add Raster Datasets"
forcesr = "NO_FORCE_SPATIAL_REFERENCE"
subfolder = "NO_SUBFOLDERS"
duplicate = "EXCLUDE_DUPLICATES"
buildpy = "BUILD_PYRAMIDS"
calcstats = "CALCULATE_STATISTICS"
buildthumb = "NO_THUMBNAILS"
result = arcpy.AddRastersToMosaicDataset_management(
mdname, rastype, inpath, updatecs, updatebnd, updateovr,
maxlevel, maxcs, maxdim, spatialref, inputdatafilter,
subfolder, duplicate, buildpy, calcstats,
buildthumb, comments, forcesr)
print("end add")
print(result)
def listRaster():
arcpy.env.workspace = mygdb = u'/mosaic/mosaic/gdbs/data.gdb'
# Get and print a list of GRIDs from the workspace
rasters = arcpy.ListDatasets("*")
for raster in rasters:
print(raster)
if __name__ == "__main__":
print("start main ")
# addGRB2ToMosaic("Z_NAFP_C_BABJ_20170906051033_P_CLDAS_RT_CHN_0P05_HOR-TEM-2017090605.GRB2")
addGRB2ToMosaic("")
listRaster()