GIS軟件實踐與開發(fā)-ArcPy_第1頁
GIS軟件實踐與開發(fā)-ArcPy_第2頁
GIS軟件實踐與開發(fā)-ArcPy_第3頁
GIS軟件實踐與開發(fā)-ArcPy_第4頁
GIS軟件實踐與開發(fā)-ArcPy_第5頁
已閱讀5頁,還剩12頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

實習(xí)報告

實習(xí)名稱:GIS軟件實踐與開發(fā)

學(xué)號:

學(xué)生姓名:

指導(dǎo)教師:

專業(yè)班級:

院(部):空間信息與測繪工程學(xué)院

2020年7月18日

實習(xí)評定表

指導(dǎo)老師評語:

成績:

指導(dǎo)老師:

年月日

目錄

目錄........................................................................3

任務(wù)一數(shù)據(jù)統(tǒng)計............................................................4

一、實習(xí)概況.............................................................4

二、實習(xí)目的.............................................................4

三、實習(xí)內(nèi)容.............................................................4

四、實習(xí)步驟.............................................................4

五、實習(xí)心得.............................................................7

任務(wù)二數(shù)據(jù)轉(zhuǎn)換............................................................8

一、實習(xí)概況.............................................................8

二、實習(xí)目的.............................................................8

三、實習(xí)內(nèi)容.............................................................8

四、實習(xí)步驟.............................................................8

五、實習(xí)心得...........................................................11

任務(wù)三派生數(shù)據(jù)...........................................................11

一、實習(xí)概況............................................................11

二、實習(xí)目的............................................................11

三、實習(xí)內(nèi)容............................................................11

四、實習(xí)步驟............................................................11

五、實習(xí)心得............................................................13

任務(wù)四分析?提取水系.......................................................13

一、實習(xí)概況............................................................13

二、實習(xí)目的............................................................13

三、實驗內(nèi)容............................................................14

四、實習(xí)步驟............................................................14

五、實習(xí)心得.............................................................17

實驗總結(jié).................................................................17

................................................................................................................................................................................................17

任務(wù)一數(shù)據(jù)統(tǒng)計

一、實習(xí)概況

1、實習(xí)時間:2020.5.11-2020.5.12

2、實習(xí)地點:疫情原因在家實習(xí)

3、實習(xí)安排:利用ArcPy進(jìn)行數(shù)據(jù)處理與制圖

4、使用軟件:ArcGIS10.7

5、使用數(shù)據(jù):Dcmol

二、實習(xí)目的

1、學(xué)習(xí)使用ArcPy進(jìn)行數(shù)據(jù)統(tǒng)計;

2、理解ArcPy的工作流程。

三、實習(xí)內(nèi)容

1、利用ArcPy進(jìn)行數(shù)據(jù)統(tǒng)計;

2、理解ArcPy的代碼含義。

四、實習(xí)步驟

1、統(tǒng)計每個縣不同地塊類型的面積

常使隔模式打開文件如果文件存在直接打開:如果文件不存在會創(chuàng)建一個文件然后打開

fl=open('D:/testl.txt,w')tfpython中文件的路徑是用"/'

fl.close()

rows=drcpy.SedrchCursor(fc)

row=rows.nextO

#使用搜索游標(biāo)搜索每一行#

ifrow.getValue("XIAN")notinuniqueList:

uniqueList.append(row.getValue("XIAN'));

#通過設(shè)置唯一值來判斷不同縣,如果“XIAN”不在唯一值列表里,追加唯一值

“XIAN”#

I

forrowsinsearchcur:

value+=row3.getValue("MIANJr)

#通過搜索每一行對同一縣的面積進(jìn)行累加#

Hdemol.py-C:\Users\Administrator\Desktop\demos\Demo1\demo1.p...□X

FileEditFormatRunOptionsWindowHelp

(importos,sys,arcpy

f=open(r,C:\Users\Adjninistrator\Desktop\dejnos\Demol\Data\resultl.txt*/w?)

fc=r'C:\Users\Administrator\Desktop\denios\Dejnol\Data\testdata.shp'

rows=arcpy.SearchCursor(fc)

row=rows.next()

uniqueList=[]

uniqueListDILE1=[]

whilerow:

ifrow.getValue(MXIAN?,)notinuniqueList:

uniqueList.append(row.getValue(^XIAN")):

row-rows.next.()

foriinrange(0,len(uniqueList)):

filter=uniqueList[i]

xian='"X]:Ar'"+filter+…

cur=arcpy.SearchCursor(fc,xian)

forrow2incur:

whilerow2:

ifrow2.getValue(DI_LEIA)notiniiniqueListDILEI:

uniqueListDILEI.append(row2.getValue(?,DI_LEI"))

row2=cur.next()

forkinrange(0,len(uniqueListDILEI)):

flt=uniqueListDILEI[k]

dilei='"DI_LErIt+"AND"+xian

print(dilei+"M)

searchcur=arcp5r.SearchCursor(fc,dilei)

value=0.0

forrow3insearchcur:

value—row3.getValue('MIAN_JIA')

print(value)

f.writelines([filter+w,flt+'%s'%value+"'n"])

f.close()

Ln:1Col:0

圖1數(shù)據(jù)統(tǒng)計的代碼界面

2、得到每個縣面積的統(tǒng)計結(jié)果,如下圖

UtPython2.7.15Shell□X

FileEditShellDebugOptionsWindowHelp

Python2.7.15(v2.7.15:ca079a3ea3,Apr302018,16:22:17)[MSCv.150032bit(In二

tel)]onWin32

Typewcopyright*,"credits"or"license?!眆ormoreinformation.

?>

========RESTART:C:\USerS\Administrator\Desktop\demos\Demol\dejnol.py

"DILEF-*0230*ANDA,XIAN"=,640323*

1.69

*DI_LEI"=,0210,AND"X二AN"='640323'

796.85

?Di-LEr-ourAND"二AT='640323'

4.91

*Di_LEr=ourAND"X二AN"='640323'

1942.68

*DI_LEr=0171"AND"X二AN"='640323'

501166

"DI_LEI"='0220’AND"X二AN"='640323'

2823.98

"DI_LE「='0131’AND"X二AN"='640323'

827.45

"DI_LE「=T631'AND"X:AN"='640323'

5.0

"DI_LEI"='0250'AND"X二AN"='640323'

859.64

"DILE「='(H2。'AND"X二AT='640323'

5.79

*DILE1-1633'AND"X二AN"-'640323'

178.07

?>l

Ln:27Col:4

圖2數(shù)據(jù)統(tǒng)計的運行界面

,resultl-記事本□

文件(F)精⑥格式(0)亙看(V)超助(H)

做032302301.69

6403230210796.85

64032301114.91

64032301411942.68

6403230171501.66

64032302202823.98

6403230131827.45

64032316315.0

6403230250859.64

64032301205.79

6403231633178.07

筑1行.足1列100%Windows(CRLF)UTF-8

圖3數(shù)據(jù)統(tǒng)計的運行結(jié)果

五、實習(xí)心得

通過ArcPy進(jìn)行數(shù)據(jù)統(tǒng)計,我學(xué)習(xí)到了ArcPy的工作流程,以及怎么用python

代碼實現(xiàn)同一縣的面積進(jìn)行累加。

任務(wù)二數(shù)據(jù)轉(zhuǎn)換

一、實習(xí)概況

1、實習(xí)時間:2020.5.13-2020.5.15

2、實習(xí)地點:疫情原因在家實習(xí)

3、實習(xí)安排:利用Arcpy進(jìn)行數(shù)據(jù)處理與制圖

4、使用軟件:ArcGIS10.7

5、使用數(shù)據(jù):Demo2

二、實習(xí)目的

1、學(xué)習(xí)使用ArcPy進(jìn)行數(shù)據(jù)轉(zhuǎn)換;

2、理解ArcPy的工作流程。

三、實習(xí)內(nèi)容

1、利用ArcPy進(jìn)行數(shù)據(jù);

2、理解ArcPy的代碼含義。

四、實習(xí)步驟

1、代碼界面

importxlrdfxlwt,arcpy

xlsPath=r*D:\pythonworkspace\gongkaikedemo\Demo2\Lot.xls,

data=xlrd.openworkbook(xlsPath)

#讀取EXCEL文件必須安裝xlrd,該代碼實現(xiàn)EXCEL文件的讀取#

point=arcpy.PointO

array=arcpy.ArrayO

#創(chuàng)建點對象,創(chuàng)建數(shù)組對象#

Qtdemo2.py-C:\Users\Administrator\Desktop\demos\Demo2\demo2.p...―□X

FileEditFormatRunOptionsWindowHelp

importxlrd,xlwt,arcpy

xlsPath=r'C:\Users\Administrator\Desktop\demos\Denio2\Lot.xls,

data=xlrd.open_workbook(xlsPath)

table=data.sheets。[0]才通過索引i順序獲取

cols=table.col_values(3)

nrows=table,nrows

point=arcpy.Point()

array=arcpy.ArrayO

polygonGeometryList=[]

cur=arcpy.InsertCursor(

C:\Users\Administrator\Desktop\demos\Demo2\data\polygon.shp")

foriinrange(1,nrows):

str=table,cell(i,3).value

name=table,cell(i,2).value

points=str.split(':')

forjinpoints:

xy=j.split')

printxy[0]

printxy[1]

print''n'

point.X=float(xy[0])

point.Y=float(xy[lj)

array.add(point)

row=cur.newRowO

row.shape=array

=name

array,removeAll()

cur.insertRow(row)

delcur

Ln:1Col:

圖4數(shù)據(jù)轉(zhuǎn)換的代碼界面

2、運行界面

[.?Python2.7.15Shell□X

FileEditShellDebugOptionsWindowHelp

34.490-

119.159

35.373

121.259

34.033

119.907

32.719

118.154

34.490

115.215

31.642

116.570

32.936

118.384

31.311

116.899

29.959

115.215

31.642

?>

Ln:325Col:4

圖5數(shù)據(jù)轉(zhuǎn)換的運行界面

3、處理結(jié)果展示如下,實現(xiàn)字符串轉(zhuǎn)面

Q/M52-ox

心皿Me-BookxMritO?*CK**^Hdp

□a<??[a皿g

、、正。::::**-*?-MeA聞p3

;5

。

圖6數(shù)據(jù)轉(zhuǎn)換的運行結(jié)果

五、實習(xí)心得

通過利用ArcPy進(jìn)行數(shù)據(jù)轉(zhuǎn)換,我學(xué)習(xí)到了使用xlrd進(jìn)行excel文件的讀取,而

且利用ArcPy進(jìn)行數(shù)據(jù)轉(zhuǎn)換還能實現(xiàn)其他數(shù)據(jù)文件的轉(zhuǎn)換,作用很大。

任務(wù)三派生數(shù)據(jù)

一、實習(xí)概況

1、實習(xí)時間:2020.5.15-2020.5.18

2、實習(xí)地點:疫情原因在家實習(xí)

3、實習(xí)安排:python地理處理與制圖

4、使用軟件:ArcGIS10.7

5、使用數(shù)據(jù):Demo3

二、實習(xí)目的

1、學(xué)習(xí)使用ArcPy生成派生數(shù)據(jù):

2、理解ArcPy的工作流程。

三、實習(xí)內(nèi)容

1、利用ArcPy生成派生數(shù)據(jù);

2、理解ArcPy的代碼含義。

四、實習(xí)步驟

1、代碼界面

line=r"D:\pythonworkspace\gongkaikedemo\Demo3\line.shp"

#輸入線數(shù)據(jù)#

mempoint=arcpy.CreateFeatureclass_management('in_memoryn,"mempoint","POINT",

,DISABLED;'DISABLED',line)

#創(chuàng)建一個要素類"mem_point”#

arcpy.AddField_management(mem_point,"LineOID","TEXT")

arcpy.AddField_management(mem_point,"Value","TEXT")

#添加兩個字段“LineOID”“Value”#

[或demo3.py-C:\Users\Administrator\Desktop\demos\Demo3\demo3.p...□X

FileEditFormatRunOptionsWindowHelp

h-inportarcpy

line=r"C:\Users\Admimstrator\Desktop\demos\Demo3\line.shp"

distance=200

output=r"C:\Users\Acbiinistrator\Desktop\demos\Deiio3\mygdb.gdb\mypoint"

mem_point=arcpy.CreateFeaturec1ass_management(''in_memory",Mmem_pomt\"PONT

arcpy.AddField_management(mem_point,“LineOID","TEXT")

arcpy.AddFleid_management(mem_point,“Value”,*TEXT")

result=arcpy.GetCount_management(line)

features=int(result.getOutput(0))

fields=["SHAPE@",

witharcpy.da.SearchCursor(line,(fields))assearch:

witharcpy.da.InsertCursor(jnejn_point,("SHAPE@",VLineOID","Value))asins

forrowinsearch:

try:

line_geom=row[0]

length=float(line_geom.length)

count=distance

oid=str(row[l])

start=arcpy.PointGeometry(line_geom.firstPoint)

end=arcpy.PointGeometry(line_geon.lastPoint)

whilecountClength:

point=line_geom.positionAlongLine(count,False)

insert.insertRow((point,oid,count))

count+=distance

exceptExceptionase:

printe.message

arcpy.CopyFeatures_management(mem_point,output)

arcpy.De1ete_management(jnem_point)

Ln:1Col:0

圖7生成派生數(shù)據(jù)的代碼界面

2、運行結(jié)果如下圖

圖8生成派生數(shù)據(jù)的運行結(jié)果

五、實習(xí)心得

通過利用ArcPy生成派生數(shù)據(jù),我學(xué)習(xí)到了如何使用ArcPy添加字段合創(chuàng)建要

素類,而且還理解了本于線要素的遍歷過程。

任務(wù)四分析?提取水系

一、實習(xí)概況

1、實習(xí)時間:2020.5.20-2020.5.22

2,實習(xí)地點:疫情原因在家實習(xí)

3、實習(xí)安排:利用Arcpy進(jìn)行數(shù)據(jù)處理與制圖

4、使用軟件:ArcGIS10.7

5、使用數(shù)據(jù):Demo4

二、實習(xí)目的

1、學(xué)習(xí)使用ArcPy進(jìn)行分析-提取水系;

2、理解ArcPy的工作流程。

三、實驗內(nèi)容

1、利用ArcPy進(jìn)行分析-提取水系;

2、理解ArcPy的代碼含義。

四、實習(xí)步驟

1、代碼界面

CreateFile<3DB(out_folder_path,out_name,{out_version})

mygdb=arcpy.CreateFileGDB_management(path,Bmygdb")

#創(chuàng)建“mygdb”的文件地理數(shù)據(jù)庫,將返回值賦給新變量mygdb#

arcpy.env.workspace=path+'/mygdb.gdb'

outpath=path+"/mygdb.gdb"

input_dem=r"C:\Users\Administrator\Desktop\demos\Demo5\riverResult.gdb\elevationn

#在輸入路徑/mygdb.gdb的工作空間下,輸入給出的高程數(shù)據(jù)#注意:

如果輸出地理數(shù)據(jù)庫名稱不包含.gdb擴(kuò)展名,則會添加這樣一個擴(kuò)展名.

demo5.py-C:\Users\Administrator\Desktop\demos\Demo5\demo5.p...□X

FileEditFormatRunOptionsWindowHelp

importarcpy

fromarcpy.saimport*

pathnr"C:\Users\Administrator\Desktop\dejnos\Demo5A,

jnygdb=arcpy.CreateFi1eGDB_management(path,"mygdb")

arcpy.env.workspace=path+/mygdb.gdb”

outpath=path+/mygdb.gdb'

input_dem=r"C:\Users\Admimstrator\Desktop\demos\Demo5\riverResult.gdb\elevation

/checkSAExtension

ifarcpy.CheckExtension(Spatial)-Available*":

arcpy.CheckOutExtension(Spatial)

illdemdata

outFill=arcpy.sa.Fill(input_dem)

outFill.save(outpath+7outfillw)

#calculateflowdirrection

outdirection=arcpy.sa.FlowDirection(outFill,FORCEDflow_direction_type='D8")

outdirection.save(outpath+7outdir)

^calculateFlowAccumulation

outAcc=arcpy.sa.F1owAccumulation(outdirection)

outAcc.save(outpath+/outAcc*")

#rcclassraster

outreclass=arcpy.sa.Reclassify(outAcc,Value",RemapRange([[0,1000,0],[1001,30699

outre

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論