How do results from a Python script get added to an ArcGIS map? [duplicate]

المشرف العام

Administrator
طاقم الإدارة
This question already has an answer here:


I have a Python script for ArcGIS that makes a new feature class. I can add this to ArcGIS as a new Script (without parameters), however the resulting feature class is not automatically added to the map layers. How does this happen? Here is an example of my Python script:

import osimport arcgisscriptingout_feat_class = 'out.shp'workspace = r'C:\temp'os.chdir(workspace)gp = arcgisscripting.create(9.3)gp.toolbox = 'management'gp.workspace = workspace# Create feature classgp.CreateFeatureclass(workspace, out_feat_class, 'POINT')# Add a field to itgp.AddField(out_feat_class, 'Value', 'DOUBLE')# Get insert cursorrows = gp.InsertCursor(out_feat_class)feat = rows.NewRow()# Set attribute datafeat.SetValue('Value', 123.45)# Set geometryptObj = gp.CreateObject('Point')ptObj.x = 101.224ptObj.y = 442.440feat.Shape = ptObj# Add to feature classrows.InsertRow(feat)# Done, clean updel ptObj, feat, rowsThere are no errors, a feature class is made, but it does not automatically appear in the map. I'm using ArcGIS 10.0, but I'd like this to be backwards compatible with ArcGIS 9.3.



أكثر...
 
أعلى