Arcgis 10中的python

1,116 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,116
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Arcgis 10中的python

  1. 1. Geoprocessing GIS Ð ×' Ñ Tools Modeling Python / " ü &Ó 5' /Ó /Ó 3 /" ArcGIS 10 ü / By diligentpig $UF*,6 3WKRQ ' GeoVisualization Geoprocessing Ð > × 9.0 ,' ArcGIS þ 5' ü Python Ð ñ Ü Python ü ArcPy GeoData '
  2. 2. By diligentpig Python ArcGIS Ñ 9.2 ,' arcgisscripting module 9.3 ,' Python List ArcGIS 10 / ArcPy site-package arcgisscripting module Ñð ArcPy /" ÞÐ > % > ' / Python %# %#=# %# > ArcPy 800+ Ü/ Geoprocessing Tools , Python IDE Þ ! cursors geometry / classes % NumPy / NumPyArrayToRaster RasterToNumPyArray Ý DUFJLVVFULSWLQJ Ñ DUFS # 9.3 import arcgisscripting gp = arcgisscripting.create(9.3) array1 = gp.createobject("array") # 10.0 import arcpy array2 = arcpy.Array() Python Window
  3. 3. By diligentpig ArcGIS 10 Python Window ' Python Python ,' command line window Þ+ / ArcPy Þ Command ø%'" command line Python Window C & Python & ' > Python Window ArcPy Þ ü tools environments Ü/ Python 3ü ! 6 3 Python Window Þ IDE PythonWin ! ü Interactive Window > ! Python " Geoprocessing tools > Python & Python Window & Python Ð Python Window Ñ& Python IDE
  4. 4. By diligentpig & / Ù ÑE > ö Ý ÐÑ ArcPy Python Window ' à Ý / *HRSURFHVVLQJ WRROV >>> import arcpy >>> arcpy.env.workspace = r'C:UsersesrichinaDesktopdemo_arcgis10pythondataUS A_Data.gdb' >>> arcpy.Buffer_analysis(&quot;Cities&quot;,&quot;Cities_buffer&quot;,&quot;5 Kilometer&quot;) <Result 'C:UsersesrichinaDesktopdemo_arcgis10pythondat aUSA_Data.gdbCities_buffer'> >>> E / Buffer Python Window >>> / 5 3 7LS $UF3 !
  5. 5. By diligentpig 7LS > ArcGIS 10 Python Window & r'C:UsersesrichinaDesktopdemo_arcgis10pythondata USA_Data.gdb' Catalog FeatureClass Python Window / 7LS % &quot; C & fcs & Python List u unicode Ý $XWRPDWLRQ
  6. 6. By diligentpig >>> import arcpy >>> arcpy.env.workspace = r'C:UsersesrichinaDesktopdemo_arcgis10pythondataUS A_Data.gdb' >>> for feature in arcpy.SearchCursor(&quot;States&quot;,&quot;STATE_NAME = 'California'&quot;): ... arcpy.Clip_analysis(&quot;States&quot;,feature.Shape,&quot;California&quot;) ... >>> 'Ý / SearchCursor × States California Feature + States Clip × / California 7LS ø&quot; ArcToolbox Clip Ó % Ð6& / Python 5' &quot;Ù Clip % >>> fcs = arcpy.ListFeatureClasses() >>> fcs.remove(&quot;California&quot;) >>> for fc in fcs: ... arcpy.Clip_analysis(fc,&quot;California&quot;,fc+&quot;_clip&quot;) ... >>> Ñ' Ð for / / California FeatureClass &quot; 7LS 3WKRQ :LQGRZ / 3WKRQ ü / remove ø% California D fcs & Python List 7LS %DFNJURXQG *HRSURFHVVLQJ
  7. 7. By diligentpig ArcGIS 10 Background Geoprocessing Geoprocessing ArcGIS Ü/ CPU Ð D &/ ArcGIS 3 ' Geoprocessing 'Ý Þ+ ArcMap Background Geoprocessing ' > + 'Ý Ü/ for ' ArcPy Modules D ' Ñø% ArcPy 3 /' Python 5' ü arcpy.mapping Mapping module .mxd .lyr /' &quot; PDF arcpy.sa Spatial Analyst module /' / ArcGIS 10 ArcPy.Raster ë % arcpy.ga Geostatistical Analyst module /' Ô modules ' &quot;' à ÑE× Mapping module Ý Ý / 0DSSLQJ 0RGXOH ü ã% >>> import arcpy, arcpy.mapping >>> mxd = arcpy.mapping.MapDocument(&quot;current&quot;) >>> df = arcpy.mapping.ListDataFrames(mxd)[0] >>> updatelyr = arcpy.mapping.ListLayers(mxd)[0] >>> sourcelyr = arcpy.mapping.Layer(r'C:heli.lyr') >>> arcpy.mapping.UpdateLayer(df,updatelyr,sourcelyr,True)
  8. 8. By diligentpig >>> / mapping module MapDocument mxd / Ü/ current C ArcMap &quot; / ListDataFrames ø% List mxd DataFrame /Ó mxd Ð DataFrame &quot; / Ð DataFrame updatelyr & Ð / &Ð sourcelyr â 1 3 UpdateLayer ø% lyr ã% True % ã% &&quot; D % & ' &quot; Ñ >>> arcpy.RefreshContents() >>> arcpy.RefreshGraphics() >>> &quot;
  9. 9. By diligentpig 7LS arcpy.RefreshContents() / ' ArcMap TOC MapView &quot; LayoutView arcpy.RefreshGraphics() /' Tip8 â / MapDocument save/saveACopy 'â mxd &quot; ã% Ý &quot;
  10. 10. By diligentpig 'Ý C:MXDs % mxd Python &quot; &quot; Ð PDF mxd Ð 7LS 3WKRQ :LQGRZ 6DYH /RDG â .py Python Window > C Load .py &quot;&quot; Python Window save .py + â Ü/ ArcGIS 10 Python 5' Geoprocessor ArcPy arcgisscripting % Ñ Python ü Python Module / % # 5' > Ñ Python 5' Ñ &quot;Ù /' ArcGIS 10 ' Python

×