+ Reply to Thread
Results 1 to 4 of 4

Thread: DGN TIN to ESRI TIN/Raster

  1. #1
    Mark Wilson
    Join Date
    Apr 2011
    Posts
    6
    Points
    0
    Answers Provided
    0


    0

    Default DGN TIN to ESRI TIN/Raster

    Hi,

    I am trying to convert some TINs that are in Microstation DGN files to ESRI raster format.

    I wrote a script that converted the 3d polylines in the DGN file to an ESRI TIN then to a raster. This worked great for about half of the files.

    As for the other half, I can't even get the geometry to display in the ArcCatalog Preview window. I can open the DGN files with the free Microstation Viewer app. I can also use Data Interoperability Quick Import to pull the tin into a FGDB as polygons with Z values. The problem with this is that when I try to use those polygons to build a TIN, it not only takes forever, only a very small slice on the right side of the tile is converted.

    This really can't be that hard can it? Any ideas on a better way to do the conversion would be appreciated.

    Mark

    PS - I have also tried Spatial ETL without much success.

  2. #2
    Sara Gilbert
    Join Date
    Jun 2010
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: DGN TIN to ESRI TIN/Raster

    Mark,

    I'm attempting the same thing. Please let me know if you had any success.

    Thanks, Sara

  3. #3
    Mark Wilson
    Join Date
    Apr 2011
    Posts
    6
    Points
    0
    Answers Provided
    0


    0

    Default Re: DGN TIN to ESRI TIN/Raster

    I will post the script that i used. I think that it ended up working but can't remember for sure since it was almost a year ago.
    # Converts multiple DGN TIN files to ESRI elevation raster
    # Mark Wilson
    # May 2011

    # -------------------------------------------------------------------------
    # Imports
    # -------------------------------------------------------------------------

    import os
    import time
    import sys
    import arcpy

    # Check out any necessary licenses
    arcpy.CheckOutExtension("3D")

    # Set environments
    arcpy.env.overwriteOutput = True

    # -------------------------------------------------------------------------
    # Variables
    # -------------------------------------------------------------------------

    DGN_folder = r"D:\"
    output_folder = r"D:\"
    sr = "PROJCS['HENNEPIN COUNTY',GEOGCS['GCS_User_Defined',DATUM['D_User_Defined',SPHEROID['User_Defined_Spheroid',6378418.941,298.2572242549207]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',100000.0],PARAMETER['Central_Meridian',-93.38333333333334],PARAMETER['Standard_Parallel_1',44.88333333333333],PARAMETER['Standard_Parallel_2',45.13333333333333],PARAMETER['Latitude_Of_Origin',44.79111111111111],UNIT['Foot_US',0.304800609601219]]"
    dont_list = [] #['1tin_v8.dgn', '2tin_v8.dgn', '10tin_v8.dgn', '11tin_v8.dgn', '12tin_v8.dgn', '13tin_v8.dgn', '14tin_v8.dgn', '15tin_v8.dgn', '16tin_v8.dgn', '17tin_v8.dgn', '18tin_v8.dgn', '19tin_v8.dgn', '20tin_v8.dgn', '21tin_v8.dgn', '22tin_v8.dgn', '23tin_v8.dgn', '24tin_v8.dgn', '25tin_v8.dgn', '26tin_v8.dgn', '27tin_v8.dgn', '28tin_v8.dgn', '29tin_v8.dgn', '30tin_v8.dgn', '31tin_v8.dgn', '32tin_v8.dgn', '33tin_v8.dgn', '34tin_v8.dgn', '35tin_v8.dgn', '36tin_v8.dgn', '37tin_v8.dgn', '38tin_v8.dgn', '3tin_v8.dgn', '40tin_v8.dgn', '41tin_v8.dgn', '46tin_v8.dgn', '4tin_v8.dgn']
    logfile = output_folder + "\\DGNTIN_to_raster_log.txt"
    bail = False

    # -------------------------------------------------------------------------
    # Functions
    # -------------------------------------------------------------------------

    def scan_dir(folder, filetype = "dgn", subdir = False):
    '''scans a directory for files of a specific extension and returns them in a list'''
    file_names = []
    ext_len = len(filetype)
    items = os.listdir(folder)
    for item in items:
    if item[- (ext_len + 1):] == "." + filetype:
    file_names.append(item)
    for item in file_names:
    print item
    f.write(item)
    f.write("\n")
    return file_names

    def DGN_to_GDB(DGN_name, DGN_workspace, out_workspace):
    '''Takes a TIN in Microstation DGN format and creates a GDB
    by using the Data Interoperability Quick Import
    This also assumes that you can correctly identify the correct parameters for the
    Quick Import tool (possibly by creating a Model Builder model and exporting to
    Python)'''
    f.write("\n\n PROCESSING ")
    f.write(str(DGN_name))
    DGN_path = DGN_workspace + "\\" + DGN_name
    print "\n PROCESSING ", DGN_path
    parameter = []
    parameter.append('''DGNV8,''')
    parameter.append(DGN_path)
    parameter.append(''',"RUNTIME_MACROS,""METAFILE,dgnv8,_XPNDCELL,YES,_PRESERVE_INSERTS,NO,EXPAND_UNNAMED_CELLS,NO,PRESERVE_UNNAMEDCELL_INSERTS,NO,SPLIT_MULTITEXT,YES,_TEXTTAGS,NO,EXPLODE_DIMENSION_ELEM,YES,_DROP_COMPLEX,NO,READ_XREF_FILES,NO,USE_XREF_PARENT_MODEL,NO,READ_XREF_UPTO_FIRST_LVL,NO,_IGDS_MSLINKS,NO,_IGDS_FRAMME,NO,_IN_UNITS,IGDS_MASTER_UNITS,OVERRIDE_GLOBAL_ORIGIN,NO,_UOR_GLOBAL_ORIGIN_X,,_UOR_GLOBAL_ORIGIN_Y,,APPLY_WORLD_FILE,YES,_MERGE_SCHEMAS,YES"",META_MACROS,""SourceMETAFILE,dgnv8,Source_XPNDCELL,YES,Source_PRESERVE_INSERTS,NO,SourceEXPAND_UNNAMED_CELLS,NO,SourcePRESERVE_UNNAMEDCELL_INSERTS,NO,SourceSPLIT_MULTITEXT,YES,Source_TEXTTAGS,NO,SourceEXPLODE_DIMENSION_ELEM,YES,Source_DROP_COMPLEX,NO,SourceREAD_XREF_FILES,NO,SourceUSE_XREF_PARENT_MODEL,NO,SourceREAD_XREF_UPTO_FIRST_LVL,NO,Source_IGDS_MSLINKS,NO,Source_IGDS_FRAMME,NO,Source_IN_UNITS,IGDS_MASTER_UNITS,SourceOVERRIDE_GLOBAL_ORIGIN,NO,Source_UOR_GLOBAL_ORIGIN_X,,Source_UOR_GLOBAL_ORIGIN_Y,,SourceAPPLY_WORLD_FILE,YES"",METAFILE,dgnv8,COORDSYS,""""""ESRIWKT|HENNEPIN COUNTY|PROJCS[""""HENNEPIN COUNTY"""",GEOGCS[""""GCS_User_Defined"""",DATUM[""""D_User_Defined"""",SPHEROID[""""User_Defined_Spheroid"""",6378418.941,298.2572242549207]],PRIMEM[""""Greenwich"""",0.0],UNIT[""""Degree"""",0.0174532925199433]],PROJECTION[""""Lambert_Conformal_Conic""""],PARAMETER[""""False_Easting"""",500000.0],PARAMETER[""""False_Northing"""",100000.0],PARAMETER[""""Central_Meridian"""",-93.38333333333334],PARAMETER[""""Standard_Parallel_1"""",44.88333333333333],PARAMETER[""""Standard_Parallel_2"""",45.13333333333333],PARAMETER[""""Latitude_Of_Origin"""",44.79111111111111],UNIT[""""Foot_US"""",0.304800609601219]]"""""",IDLIST,,__FME_DATASET_IS_SOURCE__,true"''')
    parameters = '''"'''.join(parameter)
    f.write("\n")
    f.write(str(parameters))
    new_GDB_name = DGN_name[3:5] + ".gdb"
    new_GDB_path = out_workspace + "\\" + new_GDB_name
    print "new GDB path = ", new_GDB_path
    f.write("\n")
    f.write(str(new_GDB_path))
    ## if not arcpy.Exists(new_GDB_path):
    try:
    arcpy.QuickImport_interop(parameters, new_GDB_path)
    print arcpy.GetMessages()
    f.write("\n")
    f.write(str(arcpy.GetMessages()))
    f.write("\n")
    except:
    print arcpy.GetMessages()
    f.write("\n")
    f.write(str(arcpy.GetMessages()))
    f.write("\n")
    if bail: sys.exit()

    return new_GDB_name

    def GDB_to_TIN(GDB_name, GDB_workspace, out_workspace):
    '''Takes a GDB and uses all of the polygon feature classes with Z values
    to create a new ESRI TIN'''
    GDB_path = GDB_workspace + "\\" + GDB_name
    print "\n\n GDB path = ", GDB_path
    arcpy.env.workspace = GDB_path
    FCs = arcpy.ListFeatureClasses()
    print "FCs = ", FCs
    FC_params = []
    for FC in FCs:
    FC_path = GDB_path + "\\" + FC
    print "FC path = ", FC_path
    desc = arcpy.Describe(FC_path)
    ## if desc.HasZ:
    FC_params.append("'" + FC_path + "' Shape.Z hardline <None>")
    print "\n FC params = ", FC_params
    params = ";".join(FC_params)
    print params
    f.write("\n")
    f.write(params)
    f.write("\n")
    new_TIN_name = "TIN_" + GDB_name[:2]
    new_TIN_path = out_workspace + "\\" + new_TIN_name
    try:
    arcpy.CreateTin_3d(new_TIN_path, "", params, "CONSTRAINED_DELAUNAY")
    print arcpy.GetMessages()
    f.write("\n")
    f.write(str(arcpy.GetMessages()))
    f.write("\n")
    try:
    time.sleep(30)
    arcpy.Delete_management(GDB_path, "")
    f.write("\n")
    f.write(str(arcpy.GetMessages()))
    f.write("\n")
    except:
    print arcpy.GetMessages()
    f.write("\n")
    f.write(str(arcpy.GetMessages()))
    f.write("\n")
    if bail: sys.exit()
    except:
    print arcpy.GetMessages()
    f.write("\n")
    f.write(str(arcpy.GetMessages()))
    f.write("\n")
    if bail: sys.exit()

    return new_TIN_name

    def TIN_to_raster(TIN_name, TIN_workspace, out_workspace):
    '''Converts an ESRI TIN to raster'''
    TIN_path = TIN_workspace + "\\" + TIN_name
    raster_name = TIN_name[4:6]
    raster_path = out_workspace + "\\" + raster_name
    try:
    print TIN_path
    print raster_path
    arcpy.TinRaster_3d(TIN_path, raster_path, "FLOAT", "LINEAR", "CELLSIZE 5", "1")
    f.write("\n")
    f.write(arcpy.GetMessages())
    f.write("\n")
    try:
    arcpy.Delete_management(TIN_path, "")
    except:
    print arcpy.GetMessages()
    if bail: sys.exit()
    except:
    print arcpy.GetMessages()
    f.write("\n")
    f.write(str(arcpy.GetMessages()))
    f.write("\n")
    if bail: sys.exit()

    def main():
    arcpy.CheckOutExtension("3D")
    DGN_list = scan_dir(DGN_folder, "dgn")

    for TIN in DGN_list:
    if TIN not in dont_list:
    new_GDB = DGN_to_GDB(TIN, DGN_folder, output_folder)
    new_TIN = GDB_to_TIN(new_GDB, output_folder, output_folder)
    TIN_to_raster(new_TIN, output_folder, output_folder)

    # -------------------------------------------------------------------------
    # Body
    # -------------------------------------------------------------------------

    start_time = time.clock()


    f = open(logfile, 'w')
    main()
    f.close()

    print
    print "*" * 80
    stop_time = time.clock()
    elapsed_time = stop_time - start_time
    print "Start Time: ", start_time
    print "Stop Time: ", stop_time
    print "Elapsed time = " + str(round(elapsed_time / 60, 1)) + " minutes"
    print "*" * 80




    good luck!

  4. #4

    Join Date
    Mar 2012
    Posts
    3
    Points
    0
    Answers Provided
    0


    0

    Default Re: DGN TIN to ESRI TIN/Raster

    Good boy!

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts