POST
|
I have looked through the forum, online help and the web and can't find much help on this. I am trying to: 1. Detect polylines with arcs or bezier curves in them 2. Read the geometry so i can find the intersection point of the curve and another line The forums have helped me detect arcs and curves in feature classes (not shapefiles) by checking for a difference in the length property and a computed length based on the calculated length from vertex to vertex. Thanks forum members. I still can't find any answers about the geometry though. Any help would be greatly appreciated. Mark
... View more
05-30-2012
12:35 PM
|
0
|
1
|
587
|
POST
|
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!
... View more
03-06-2012
10:39 AM
|
0
|
0
|
1076
|
POST
|
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.
... View more
05-27-2011
03:07 PM
|
0
|
5
|
5377
|
POST
|
Hi all, I am trying to: - read data from a .dbf file - caculate some statistics - then read in another .dbf file with some point coordinates - joint the two together - then create a shapefile - and finally create points in the shapefile with the statistical data in them Everything is peachy except that things fail when i try to write a floating point value to a field in the newly created shapefile. Records that contain zeros write to the file just fine. I have tried everything i can think of to make it work including defining the field as Double, Float as well as trying to format the statistics numbers before writing them with the Decimal module that comes with Python. Below is my code. Also included is some sample output that shows one record that worked and one that did not. It is interesting that no output comes out of the GetMessages when the write fails. Note: the code seems to fail at the following command: feature.setValue(tot_consumption, dmd_dict[key][1]) # create fields street_number = "Strt_Num" street_name = "Strt_Name" city = "City" APN = "APNNODASH" tot_days = "Total_days" tot_consumption = "Total_cons" ADD_fld = "ADD_gpm" MDD_fld = "MDD_gpm" try: arcpy.AddField_management(FC, street_number, "Text", "", "", 32) arcpy.AddField_management(FC, street_name, "Text", "", "", 32) arcpy.AddField_management(FC, city, "Text", "", "", 32) arcpy.AddField_management(FC, APN, "Text", "", "", 32) arcpy.AddField_management(FC, tot_days, "Long", 8,) arcpy.AddField_management(FC, tot_consumption, "Float", 12, 6) arcpy.AddField_management(FC, ADD_fld, "Float", 12, 6) arcpy.AddField_management(FC, MDD_fld,"Float", 12, 6) except: print arcpy.GetMessages() # create points linked_count = 0 not_linked_count = 0 cursor = arcpy.InsertCursor(FC) for key in dmd_dict: newkey = key[1], key[2], key[3] print "NEWKEY ", newkey try: link_values = links[newkey] # looks up the values in the link table for APN, X, Y linked_count += 1 print "LINKS ", link_values vertex = arcpy.CreateObject("Point") print "chkpt a" print "X = ", link_values[1] vertex.X = link_values[1] print "chkpt b" print "Y = ", link_values[2] vertex.Y = link_values[2] print "chkpt c" feature = cursor.newRow() print "chkpt d" feature.shape = vertex print "chkpt e" feature.setValue(street_number, key[1]) print "chkpt f" feature.setValue(street_name, key[2]) print "chkpt g" feature.setValue(city, key[3]) print "chkpt h" feature.setValue(APN, link_values[0]) print "chkpt i" print dmd_dict[key][0] feature.setValue(tot_days, int(dmd_dict[key][0])) print "chkpt j" print dmd_dict[key][1] feature.setValue(tot_consumption, dmd_dict[key][1]) print "chkpt k" print dmd_dict[key][2] feature.setValue(ADD_fld, dmd_dict[key][2]) print "chkpt l" print dmd_dict[key][3] feature.setValue(MDD_fld, dmd_dict[key][3]) print "chkpt m" cursor.insertRow(feature) except: not_linked_count += 1 print "NOT LINKED", key for item in key: f.write(str(item) + "\t") length = len(dmd_dict[key]) for index in range(length): f.write(str(dmd_dict[key][index])) if index != length - 1: f.write("\t") f.write("\n") print arcpy.GetMessages(2) NEWKEY ('1470', 'PROSPECT AVE', 'CAPITOLA') LINKS ('03404613', 6136687.2654799996, 1815503.14329) chkpt a X = 6136687.26548 chkpt b Y = 1815503.14329 chkpt c chkpt d chkpt e chkpt f chkpt g chkpt h chkpt i 1094 chkpt j 701.00000 NOT LINKED ('10990.00000', '1470', 'PROSPECT AVE', 'CAPITOLA') NEWKEY ('1525', 'PROSPECT AVE', 'CAPITOLA') LINKS ('03404502', 6136595.11974, 1815685.3788000001) chkpt a X = 6136595.11974 chkpt b Y = 1815685.3788 chkpt c chkpt d chkpt e chkpt f chkpt g chkpt h chkpt i 0 chkpt j 0 chkpt k 0.0 chkpt l 0.0 chkpt m
... View more
05-11-2011
12:25 PM
|
0
|
0
|
381
|
POST
|
OK. Thanks. Yet another reason why FGDB is preferrable over PGDB. Mark
... View more
04-27-2011
10:18 AM
|
0
|
0
|
157
|
POST
|
I am trying to create a new table in a Personal GDB. The table name is "TIME". I get a "Syntax error in FROM clause" when doing so. Is TIME a reserved word? Or is this a bug? I am using the tool in ArcToolbox. I have tried it with Arc 9.3 and Arc 10. It works fine when i try to add the same table to a File GDB. Mark
... View more
04-27-2011
09:40 AM
|
0
|
2
|
430
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|