POST
|
i solved the problem by myself # Import system modules
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
#
gp.SetProduct("ArcInfo") # or ArcEditor or ArcInfo
gp.overwriteoutput = 1
# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
gp.AddToolbox("C:/Program Files/ET GeoWizards 9.9 Floating/ET GeoWizards.tbx")
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx")
#script arguments
#orbit = "D:/f/Cap/tanProblem/output/o_90.lyr"
orbit = "D:/f/Cap/tanProblem/input/o_90.shp"
O1_mollw_90 = "o_90"
O1_mollw_90_1_Dissolve_shp = "D:/f/Cap/tandem Problem/input/o_90_Dissolve.shp"
tandem_shp = "D:/f/Cap/tanProblem/output/new/tan.shp"
tandem_Copy_shp = "D:/f/Cap/tanProblem/output/new/tan_Copy.shp"
#add join
tap_dbf = "D:/f/Cap/tanProblem/Test_o1.dbf"
v90_output = "D:/f/Cap/tanProblem/output/new"
Output_Feature_Class = "D:/f/Cap/tanProblem/output/90_output/tan_CopyFeatures.shp"
#read row of txt file
f=open("D:/f/Capa/tanProblem/Test_o13.txt","r")
for line in f.readlines(): #in huge file f.xreadlines maybe to use
werte = line.split('\t')# für tab-separate
min_row = werte[4]
max_row = werte[5]
index = werte[0]
O = werte[3]
if Orbit == "O":
continue
O = int(O)
min_row = int(min_row)
max_row = int(max_row)
index = int(index)
print "min_row=%s, max_row=%s, index=%s, O=%s" % (min_row, max_row, index, O)
Expression = "\"FID\" >= %d+90*(%d-1) AND \"FID\" <= %d+90*(%d-1)" % (min_row, O, max_row, O)
#Expression = "\"FID\" >= %min_row%+90*(%O%-1) AND \"FID\" <= %max_row%+90*(%O%-1)"
Expression_2 = "%d-3" % (index)
# Process: Select Layer By Attribute...,
gp.makefeaturelayer(o, "walk")
gp.SelectLayerByAttribute_management ('walk' , "NEW_SELECTION", Expression)
# Process: Dissolve...
gp.Dissolve_management('walk', O1_mollw_90_1_Dissolve_shp, "FID", "", "MULTI_PART", "DISSOLVE_LINES")
gp.makefeaturelayer(O1_m_90_1_Dissolve_shp, "walk2")
# Process: Calculate Field...
gp.CalculateField_management("walk2", "ID", Expression_2, "VB", "")
# Process: ET Select And Export...
gp.toolbox = "C:/Program Files/ET GeoWizards 9.9 Floating/ET GeoWizards.tbx";
gp.ET_GPSelectAndExport("walk2", tandem_shp, "")
gp.makefeaturelayer(tandem_shp, "tan")
# Process: Add Join...
gp.AddJoin_management("tan", "FID", tap_dbf, "OID", "KEEP_COMMON")
# Process: Feature Class To Shapefile (multiple)...
gp.CopyFeatures_management("tan", Output_Feature_Class, "", "0", "0", "0")
#gp.DeleteField_management(Output_Feature_Class, "Id;ET_ID;Test_o;Test_o_1;Test_o_4;Test_o_5")
gp.FeatureClassToShapefile_conversion(Output_Feature_Class, v90_output)
... View more
06-27-2011
03:11 AM
|
0
|
0
|
156
|
POST
|
Why does the following scribt not work ? # ---------------------------------------------------------------------------
# test.py
# Created on: Mi Jun 22 2011 11:23:51
# (generated by ArcGIS/ModelBuilder)
# Usage: test <o_90> <min_row> <max_row> <Zeile> <O>
# ---------------------------------------------------------------------------
# Import system modules
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
#
gp.SetProduct("ArcInfo") # or ArcEditor or ArcInfo
gp.overwriteoutput = 1
# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
gp.AddToolbox("C:/Program Files/ET GeoWizards 9.9 Floating/ET GeoWizards.tbx")
#script arguments
orbit = "D:/f/Cap/tanProblem/output/o_90.lyr"
O1_mollw_90 = "o_90"
O1_mollw_90_1_Dissolve_shp = "D:/figwer/Capacity/tandem Problem/input/orbit_90_Dissolve.shp"
tan_shp = "D:/figwer/Cap/tanProblem/output/new/tan.shp"
O1_mollw_90_1_Dissolve_shp__2_ = "D:/f/Cap/tanProblem/input/o_90_Dissolve.shp"
#read row of txt file
f=open("D:/f/Cap/tanProblem/Test_o1.txt","r")
for line in f.readlines(): #in huge file f.xreadlines maybe to use
werte = line.split('\t')# für tab-separate
min_row = werte[4]
max_row = werte[5]
index = werte[0]
O = werte[3]
if O == "O":
continue
O = int(O)
min_row = int(min_row)
max_row = int(max_row)
print "min_row=%s, max_row=%s, index=%s, O=%s" % (min_row, max_row, index, O)
Expression = "\"FID\" >= %d+90*(%d-1) AND \"FID\" <= %d+90*(%d-1)" % (min_row, O, max_row, O)
#Expression = "\"FID\" >= %min_row%+90*(%O%-1) AND \"FID\" <= %max_row%+90*(%O%-1)"
Expression_2 = "%index%-3"
# Process: Select Layer By Attribute...,
gp.makefeaturelayer(o, "walk")
gp.SelectLayerByAttribute_management ("walk" , "NEW_SELECTION", Expression)
#----------------------------------------------------------------------------------------
#übergabe funktioniert nicht
#----------------------------------------------------------------------------------------
# Process: Dissolve...
gp.Dissolve_management("walk", O1_mollw_90_1_Dissolve_shp, "FID", "", "MULTI_PART", "DISSOLVE_LINES")
# Process: Calculate Field...
gp.makefeaturelayer(O1_mollw_90_1_Dissolve_shp, "walk2")
gp.CalculateField_management("walk2", "Id", Expression_2, "VB", "")
# Process: ET Select And Export...
gp.toolbox = "C:/Program Files/ET GeoWizards 9.9 Floating/ET GeoWizards.tbx";
gp.ET_GPSelectAndExport("walk2", tan_shp, "")
... View more
06-26-2011
11:24 PM
|
0
|
1
|
497
|
POST
|
i try this with a search courser but it will no work too def Minimum(inputData, FieldName,row):
import arcgisscripting
gp = arcgisscripting.create(9.3)
inputData = "D:\Data\Test.dbf"
FieldName = "N15"
intable = inputData
infield = FieldName
# open cursor
rows = gp.searchcursor(intable)
row = rows.next()
fval = row.GetValue(infield)
gp.SetParameterAsText(2, str(fval)) and how can i define the row i want? a other problem in this code is that i get a massage: ERROR 000539: Runtime error <type 'exceptions.NameError'>: name 'gp' is not defined Failed to execute (Calculate Value). but i think i defined gp with this gp = arcgisscripting.create()
... View more
06-21-2011
09:53 PM
|
0
|
0
|
265
|
POST
|
HI i will get a value from a table dbf. for this i use the Calulate Value Tool in ArcGis 9.3 I wrote this small pyton tool but it will not work, could somebody help me Minimum("D:/data/program/test3_copy.dbf", "N15","10") def Minimum(inputData, FieldName,row): import arcgisscripting gp = arcgisscripting.create() gpResult = gp.GetCellValue(inputData, FieldName,row) print gp.AddMessage( str( gpResult.GetOutput(0) ))
... View more
06-21-2011
05:49 AM
|
0
|
2
|
2166
|
POST
|
hi I would like to split some lines after x kilometers. This schould work automaticaly, because i have to cut more than 100 Lines in different sections Is there any possibility to split polylines after x kilometers with the modelbuilder? Thanks for your help Flo
... View more
06-10-2011
01:33 AM
|
0
|
0
|
400
|
POST
|
i solved it: Dim filePath As String filePath = "D:\xxxxx\output\NEWTABLE" Dim tableName As String '######################### 'Dateiname '######################### tableName = "TSX_Capacity1.dbf" Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument Dim pWorkspace As IWorkspace Dim pFact As IWorkspaceFactory Set pFact = New ShapefileWorkspaceFactory Set pWorkspace = pFact.OpenFromFile(filePath, 0) Dim pFWorkspace As IFeatureWorkspace Set pFWorkspace = pWorkspace Dim pTable As ITable Set pTable = pFWorkspace.OpenTable(tableName) 'use the table accordingly 'MsgBox "Total rows of the table: " & pTable.RowCount(Nothing) Dim aoiStandAloneTable As IStandaloneTable Dim aoiTwin As ITableWindow Dim aoiApp As Application Set aoiApp = Application Set aoiDoc = ThisDocument Set aoiTwin = New TableWindow Set aoiTab = pTable If aoiTab Is Nothing Then MsgBox "Auf die Tabelle kann nicht zu gegriffen werden." Exit Sub End If Set aoiTwin.Table = aoiTab Set aoiTwin.Application = aoiApp aoiTwin.Show (True) and for saving i used the model builder 🙂
... View more
05-16-2011
02:30 AM
|
0
|
0
|
319
|
POST
|
hi i created a VBA Macro in with i calculate a dbf table. now i want by clicking a button that the table open i found this code but it doesn´t work. Private Sub CommandButton3_Click() Dim pDoc As IMxDocument Set pDoc = ThisDocument Dim pMap As IMap Set pMap = pDoc.FocusMap Dim sDir As String, strTableName As String sDir = "D:\file\output\NEWTABLE" strTableName = "T_Test.DBF" Dim pFact As IWorkspaceFactory Set pFact = New ShapefileWorkspaceFactory Dim pWorkspace As IWorkspace Set pWorkspace = pFact.OpenFromFile(sDir, 0) Dim pFeatWs As IFeatureWorkspace Set pFeatWs = pWorkspace Dim pTable As ITable Set pTable = pFeatWs.OpenTable(strTableName) ' Create a new standalone table and add it ' to the collection of the focus map Dim pStTab As IStandaloneTable Set pStTab = New StandaloneTable Set pStTab.Table = pTable Dim pStTabColl As IStandaloneTableCollection Set pStTabColl = pMap pStTabColl.AddStandaloneTable pStTab ' Refresh the TOC pDoc.UpdateContents End Sub before i create the dbf file i used a shape file with the next code i opened the shape file on the same way it should work with the dbf files. Dim pMXDocument As IMxDocument Set pMXDocument = ThisDocument Dim pPfad As String pPfad = "D:\File\output\NEWTABLE" Dim pShapefile As String DBFile = "T_TesT_5" Dim pwFactory As IWorkspaceFactory Set pwFactory = New ShapefileWorkspaceFactory Dim pFeatureWorkspace As IFeatureWorkspace Set pFeatureWorkspace = pwFactory.OpenFromFile(pPfad, 0) Dim pFeatureClass As IFeatureClass Set pFeatureClass = pFeatureWorkspace.OpenFeatureClass(pShapefile) Dim pFeatureLayer As IFeatureLayer Set pFeatureLayer = New FeatureLayer Set pFeatureLayer.FeatureClass = pFeatureClass pFeatureLayer.Name = "o_length" ' Hier wurde ner neue layer bennant pMXDocument.AddLayer pFeatureLayer pMXDocument.ActiveView.Refresh pMXDocument.UpdateContents 'Dim pMXDocument As IMxDocument 'Set pMXDocument = ThisDocument Dim pfLayer As IFeatureLayer Dim pMap As IMap Set pMap = pMXDocument.FocusMap Set pfLayer = pMap.Layer(1) 'pMXDocument.SelectedLayer '############### Dim pFClass As IFeatureClass Set pFClass = pfLayer.FeatureClass Dim pFCursor As IFeatureCursor Set pFCursor = pFClass.Update(Nothing, False) Dim pFeature As IFeature Dim aoiApp As Application Dim aoiDoc As IMxDocument Dim aoiStandAloneTable As IStandaloneTable Dim aoiTwin As ITableWindow Dim aoiTab As IClass Dim aoiUnknown As IUnknown Dim aoiFlayer As IFeatureLayer2 Set aoiApp = Application Set aoiDoc = ThisDocument Set aoiTwin = New TableWindow Set aoiFlayer = pMap.Layer(0) ' aoiDoc.SelectedLayer If aoiFlayer Is Nothing Then MsgBox " Es ist kein Layer ausgewählt" Exit Sub End If Set aoiTab = aoiFlayer If aoiTab Is Nothing Then MsgBox "Auf die Tabelle kann nicht zu gegriffen werden." Exit Sub End If Set aoiTwin.Table = aoiTab Set aoiTwin.Application = aoiApp aoiTwin.Show (True) at the end i want save the file by clicking another button. could somebody help me sorry for my bad english Flo
... View more
05-14-2011
12:43 PM
|
0
|
2
|
1772
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|