コード例 #1
0
def Arc_To_SAGA_Raster(Raster):
    Supported = ['sdat', 'tif', 'img', 'asc']
    for ext in Supported:
        if File_Cmp_Extension(Raster, ext):
            return Raster

    File = File_Get_TempName('tif')
    Raster = ConversionUtils.ValidateInputRaster(Raster)
    ConversionUtils.CopyRasters(Raster, File, "")

    return File
コード例 #2
0
    def Set_Input(self, Identifier, Value, Type):
        Files = None

        if Value != '#' and Value != None:
            List = ConversionUtils.SplitMultiInputs(Value)
            for Item in List:
                if Type == 'grid' or Type == 'grid_list':
                    File = Arc_To_SAGA_Raster(Item)
                elif Type == 'table' or Type == 'table_list':
                    File = Arc_To_SAGA_Table(Item)
                elif Type == 'shapes' or Type == 'shapes_list':
                    File = Arc_To_SAGA_Feature(Item)
                elif Type == 'points' or Type == 'points_list':
                    File = Arc_To_SAGA_Points(Item)
                else:
                    File = None

                if File != None:
                    if Files == None:
                        Files = File
                    else:
                        Files = Files + ';' + File

                    if File != Item:
                        self.Add_Temporary(File)

        if Files != None:
            self.Set_Option(Identifier, Files)

        return Files
コード例 #3
0
def Arc_To_SAGA_Table(Table):
    if File_Cmp_Extension(Table, 'dbf') == True:
        return Table

    File = File_Get_TempName('.dbf')
    ConversionUtils.CopyRows(Table, File)

    return File
コード例 #4
0
def SAGA_To_Arc_Feature(File, Feature):
    if File_Cmp_Extension(Feature, 'shp') == False:
        ConversionUtils.CopyFeatures(File, Feature)
        File_Remove_All(File)

    Arc_Load_Layer(Feature)

    return True
コード例 #5
0
def Arc_To_SAGA_Feature(Feature):
    if File_Cmp_Extension(Feature, 'shp') == True:
        return Feature

    File = File_Get_TempName('.shp')
    ConversionUtils.CopyFeatures(Feature, File)

    return File
コード例 #6
0
def SAGA_To_Arc_Raster(File, Raster):
    if File_Cmp_Extension(Raster, 'sdat') == False:  # conversion needed
        Tool = SAGA_Tool('io_gdal', '2')  # 'Export Raster to GeoTIFF'
        Tool.Set_Option('GRIDS', File)

        if File_Cmp_Extension(Raster, 'tif'):
            arcpy.AddMessage('Output GeoTIFF: ' + File + ' >> ' + Raster)
            Tool.Set_Option('FILE', Raster)
            if Tool.Run(True) != 0:
                return False
        else:
            arcpy.AddMessage('Output Convert: ' + File + ' >> ' + Raster)
            GeoTIFF = File_Set_Extension(File, 'tif')
            Tool.Set_Option('FILE', GeoTIFF)
            if Tool.Run(True) != 0:
                return False
            GeoTIFF = ConversionUtils.ValidateInputRaster(GeoTIFF)
            ConversionUtils.CopyRasters(GeoTIFF, Raster, "")

    Arc_Load_Layer(Raster)

    return True
コード例 #7
0
def compileASM(asm_text, outfile="output"):
    assembledFile = AssembledFile(asm_text)
    # print cpu_out
    fname, ext = os.path.splitext(outfile)

    # writing binary data to file
    with open(fname + ".bin", "wb") as binfile:
        binfile.seek(0)
        binfile.truncate()
        for word in map(lambda x: ConversionUtils.long_to_bytes(int(x, base=16)), assembledFile.hex):
            binfile.write(word)

    # writing hex string file
    with open(fname + ".hex", "w") as hexfile:
        hexfile.seek(0)
        hexfile.truncate()
        hexfile.write("\n".join(assembledFile.hex))

    print(assembledFile.hex)
    return assembledFile
コード例 #8
0
    def Set_Output(self, Identifier, Value, Type):
        Files = None

        if Value != '#' and Value != None:
            List = ConversionUtils.SplitMultiInputs(Value)
            for Item in List:
                if Type == 'grid' or Type == 'grid_list':
                    if File_Cmp_Extension(Item, 'sdat') == False:
                        File = self.Get_Temporary('sgrd')
                    else:
                        File = File_Set_Extension(Item, 'sgrd')
                elif Type == 'table' or Type == 'table_list':
                    if File_Cmp_Extension(Item, 'dbf') == False:
                        File = self.Get_Temporary('dbf')
                    else:
                        File = Item
                elif Type == 'shapes' or Type == 'shapes_list':
                    if File_Cmp_Extension(Item, 'shp') == False:
                        File = self.Get_Temporary('shp')
                    else:
                        File = Item
                elif Type == 'points' or Type == 'points_list':
                    File = self.Get_Temporary('spc')
                else:
                    File = None

                if File != None:
                    if Files == None:
                        Files = File
                    else:
                        Files = Files + ';' + File

        if Files != None:
            self.Set_Option(Identifier, Files)
            self.Add_Output(Files, Value, Type)

        return Files
コード例 #9
0
def SAGA_To_Arc_Table(File, Table):
    if File_Cmp_Extension(Table, 'dbf') == False:
        ConversionUtils.CopyRows(File, Table)
        File_Remove_All(File)

    return True
コード例 #10
0
#Define message constants so they may be translated easily
msgErrorTooFewParams = "Insufficient number of parameters provided"
msgErrorInvalidOutPath = "Output path does not exist"
msgErrorInvalidInput = " Input does not exist"
msgSuccess = "successfully converted to "
msgFailed = "Failed to convert"
now = time.localtime(time.time())
tempmdb = "CANSYSNet"+str(now[0])+"_"+str(now[1])+"_"+str(now[2])+".mdb"

try:

    # Argument 1 is the list of feature classes to be converted
    inFeatureClasses = ConversionUtils.gp.GetParameterAsText(0)

    # The list is split by semicolons ";"
    inFeatureClasses = ConversionUtils.SplitMultiInputs(inFeatureClasses)

    # The output workspace where the shapefiles are created
    outWorkspace = r"//GISDATA/arcgis/gisdata/KDOT/btp/CANSYSTEST/"+tempmdb
    #ConversionUtils.gp.GetParameterAsText(1)

    # Set the destination workspace parameter (which is the same value as the output workspace)
    # the purpose of this parameter is to allow connectivity in Model Builder.
    # ConversionUtils.gp.SetParameterAsText(outWorkspace)

    # Error trapping, in case the output workspace doesn't exist
    if not ConversionUtils.gp.Exists(outWorkspace):
        raise Exception, "%s: %s" % (msgErrorInvalidOutPath, outWorkspace)

    # Loop through the list of input feature classes and convert/copy each to the output geodatabase or folder
    for inFeatureClass in inFeatureClasses:
コード例 #11
0
    keyword = ConversionUtils.gp.GetParameterAsText(2)

    ConversionUtils.gp.workspace = workspace

    ConversionUtils.gp.SetParameterAsText(3,out_gdb)
    
    #The raster datasets in the input workspace
    in_raster_datasets = ConversionUtils.gp.ListRasters()

    #Loop through the array copying each raster dataset to the output workspace
    #in_raster_dataset = in_raster_datasets.next()

    #while in_raster_dataset <> None:
    for in_raster_dataset in in_raster_datasets:
        out_raster = ConversionUtils.GenerateRasterName(workspace + os.sep + in_raster_dataset, out_gdb, "")
        try:
            # Copy/Convert the inRaster to the outRaster
 
            ConversionUtils.CopyRasters(in_raster_dataset, out_raster, keyword)
            ConversionUtils.gp.AddMessage(msgSuccess + " %s to %s" % (in_raster_dataset, out_raster))
      
        except Exception, ErrorDesc:
            # Except block for the loop. If the tool fails to convert one of the Rasters, it will come into this block
            #  and add warnings to the messages, then proceed to attempt to convert the next input Raster.
            WarningMessage = (msgFail + " %s to %s" %(in_raster_dataset,out_raster))
            ConversionUtils.gp.AddWarning(WarningMessage)

        #in_raster_dataset = in_raster_datasets.next()
      
except Exception, ErrorDesc:
コード例 #12
0
import ConversionUtils, time

ConversionUtils.gp.Overwriteoutput = 1

#Define message constants so they may be translated easily
msgErrorInvalidOutPath = "Output path does not exist"
msgSuccess = "successfully converted to "
msgFailed = "Failed to convert "

# Argument 1 is the list of feature classes to be converted
inFeatureClasses = ConversionUtils.gp.GetParameterAsText(0)

# The list is split by semicolons ";"
inFeatureClasses = ConversionUtils.SplitMultiInputs(inFeatureClasses)

# The output workspace where the shapefiles are created
outWorkspace = ConversionUtils.gp.GetParameterAsText(1)

# Set the destination workspace parameter (which is the same value as the output workspace)
# the purpose of this parameter is to allow connectivity in Model Builder.
ConversionUtils.gp.SetParameterAsText(2, outWorkspace)

# Set the progressor
ConversionUtils.gp.SetProgressor("step",
                                 "Converting multiple feature classes ...", 0,
                                 len(inFeatureClasses))

# Loop through the list of input feature classes and convert/copy each to the output geodatabase or folder
for inFeatureClass in inFeatureClasses:
    try:
        # Set the progressor label
コード例 #13
0
Usage: TableToGeodatabase <in_table;in_table...> <out_workspace>
Usage: TableToDBase <in_table;in_table...> <out_folder>
*********************************************************************************************************************"""

import ConversionUtils
import time

#Define message constants so they may be translated easily
msgFail = ConversionUtils.gp.GetIDMessage(86153) #"Failed to convert "
msgConverting = ConversionUtils.gp.GetIDMessage(86130) #"Converting "

# Argument 1 is the list of tables to be converted
inTables = ConversionUtils.gp.GetParameterAsText(0)

# The list is split by semicolons ";"
inTables = ConversionUtils.SplitMultiInputs(inTables)

# The output workspace where the shapefiles are created
outWorkspace = ConversionUtils.gp.GetParameterAsText(1)

# Set the destination workspace parameter (which is the same value as the output workspace)
# the purpose of this parameter is to allow connectivity in Model Builder.
ConversionUtils.gp.SetParameterAsText(2,outWorkspace)
#message "Converting multiple tables ..."
ConversionUtils.gp.SetProgressor("step",ConversionUtils.gp.GetIDMessage(86175) , 0, len(inTables))
   
# Loop through the list of input tables and convert/copy each to the output geodatabase or folder
for inTable in inTables:

    try: 
        # Generate a valid output output name
コード例 #14
0
#Import required modules
import ConversionUtils, time

#Define message constants so they may be translated easily
msgWorkspace = ConversionUtils.gp.GetIDMessage(
    86109)  # Message "Output workspace does not exist: "
msgCoordinateSystem = ConversionUtils.gp.GetIDMessage(
    86110
)  #Message "Must Enter a Spatial Reference or Template Feature Class."
msgFail = ConversionUtils.gp.GetIDMessage(
    86111)  # Message "Failed to project "

#Set the input datasets
inputs = ConversionUtils.gp.GetParameterAsText(0)
# The list is split by semicolons ";"
inputs = ConversionUtils.SplitMultiInputs(inputs)

#Set the output workspace
output_workspace = ConversionUtils.gp.GetParameterAsText(1)

#Set the spatial reference
output_coordinate_system = ConversionUtils.gp.GetParameterAsText(2)

#Set the template dataset
template_dataset = ConversionUtils.gp.GetParameterAsText(3)

#Set the transformation
transformation = ConversionUtils.gp.GetParameterAsText(4)
#Message 86112   "Projecting multiple datasets ..."
ConversionUtils.gp.SetProgressor("step",
                                 ConversionUtils.gp.GetIDMessage(86112), 0,
コード例 #15
0
import ConversionUtils, time

msgWorkspace = ConversionUtils.gp.GetIDMessage(
    86127)  #"Output location does not exist: "
msgParams = ConversionUtils.gp.GetIDMessage(
    86152)  #"Insufficient number of parameters provided"
msgSuccess = ConversionUtils.gp.GetIDMessage(
    86128)  #"Successfully converted: "
msgFail = ConversionUtils.gp.GetIDMessage(86153)  #"Failed to convert "
msgConverting = ConversionUtils.gp.GetIDMessage(86130)  #"Converting "

# Argument 1 is the list of Rasters to be converted
inRasters = ConversionUtils.gp.GetParameterAsText(0)

# The list is split by semicolons ";"
inRasters = ConversionUtils.SplitMultiInputs(inRasters)

# The output workspace where the shapefiles are created
outWorkspace = ConversionUtils.gp.GetParameterAsText(1)

# The configuration keyword
keyword = ConversionUtils.gp.GetParameterAsText(2)

# Set the destination workspace parameter (which is the same value as the output workspace)
# the purpose of this parameter is to allow connectivity in Model Builder.
# ConversionUtils.gp.SetParameterAsText(2,outWorkspace)

rastercnt = len(inRasters)
ConversionUtils.gp.SetProgressor("step", msgConverting, 0, rastercnt, 1)
currentloc = 1
コード例 #16
0
*********************************************************************************************************************"""

#Importing standard library modules
import ConversionUtils, time

msgSuccess = ConversionUtils.gp.GetIDMessage(
    86119)  #"Successfully calculated statistics : "
msgFail = ConversionUtils.gp.GetIDMessage(
    86120)  #"Failed to calculate statistics : "
msgCalculating = ConversionUtils.gp.GetIDMessage(
    86121)  #"Calculating statistics on "

#The input rasters
rasterlist = ConversionUtils.gp.GetParameterAsText(0)
# The list is split by semicolons ";"
rasterlist = ConversionUtils.SplitMultiInputs(rasterlist)

# The x skip factor
xskip = ConversionUtils.gp.GetParameterAsText(1)

# The y skip factor
yskip = ConversionUtils.gp.GetParameterAsText(2)

#The ignore values
ignore = ConversionUtils.gp.GetParameterAsText(3)

#Skip existing stats
skipexist = ConversionUtils.gp.GetParameterAsText(4)

rastercnt = len(rasterlist)
#Message "Calculating statistics..."
コード例 #17
0
"""

###Import required modules
import ConversionUtils, time

#Define message constants so they may be translated easily
msgCoordinateSystem = "Must Enter a Spatial Reference or Template Geodataset."
msgInvalidParameters = "Invalid number of parameters. Spatial Reference or Template must be provided."
msgPrjAlreadyDefine = "The dataset already has a projection defined."
unknown_projection = "Unknown"

try:

    #Set the input datasets
    inputs = ConversionUtils.gp.GetParameterAsText(0)
    inDatasets = ConversionUtils.SplitMultiInputs(inputs)

    #Set the spatial reference
    out_CS = ConversionUtils.gp.GetParameterAsText(1)

    #Set the template dataset
    temp_data = ConversionUtils.gp.GetParameterAsText(2)

    #Set output boolean parameter "Completed" to false by default.
    ConversionUtils.gp.SetParameterAsText(3, 0)

    #Set output boolean parameter "Error" to false by default.
    ConversionUtils.gp.SetParameterAsText(4, 0)

    #Set the spatial reference. Check for template dataset.
    if (out_CS == "" or out_CS == "#") and (temp_data == ""