ArcGIS中轉換和傳輸資料

2021-09-16 13:32:50 字數 3206 閱讀 8892

在arcgis engine開發中,難免會遇到資料的轉移,例如將shp檔案、mdb、gdb中圖層匯入sde,從sde中匯出圖層。

嘗試了下有以下幾種方式:

通過源資料集新建空資料集,並以ifeaturebuffer將源資料集中要素逐條插入新資料集。個人認為有以下優勢:

1、可控制新建資料集的字段

2、可在插入記錄時更改記錄。如某個欄位的對映

/// /// 轉換資料

///

/// 源圖層

/// 目標圖層名

/// 目標工作空間

/// 篩選條件

public void transferdatawithbuffer(ifeatureclass sourcefclass, string fname, iworkspace targetws, ispatialfilter spatialfilter = null)

}//int flushinterval = 1000;//清空緩衝區間隔

//int current = 0;//當前記錄數

ifeaturecursor tcursor = targetfclass.insert(true);

ifeaturebuffer tbuffer = targetfclass.createfeaturebuffer();

ifeaturecursor scursor = sourcefclass.search(spatialfilter, true);

ifeature sfeature = null;

object value;

while ((sfeature = scursor.nextfeature()) != null)

tcursor.insertfeature(tbuffer);

//current++;

//if (current % flushinterval == 0)

// tcursor.flush();

}tcursor.flush();

system.runtime.interopservices.marshal.releasecomobject(scursor);

system.runtime.interopservices.marshal.releasecomobject(tbuffer);

system.runtime.interopservices.marshal.releasecomobject(tcursor);

}

1、ifeaturedataconverter將資料來源中的單個表,要素類或要素資料集轉換至另乙個資料來源中。

2、不能在目標欄位集和中新增或刪除字段,不然會導致轉換失敗,但是可以修改字段屬性

3、僅載入簡單的要素資料(點,線,多邊形)

/// /// 轉換資料

///

/// 源圖層

/// 目標圖層名

/// 目標工作空間

/// 篩選條件

public static void convertdata(ifeatureclass sourcefclass, string fname, iworkspace targetws, ispatialfilter spatialfilter = null)

", invalidobjectinfo.invalidobjectid);

}}

驗證字段:

/// /// 驗證字段

///

/// 字段集合

/// 源工作空間

/// 目標工作空間

///

public static ifields validatefields(ifields fields,iworkspace sourcewk,iworkspace targetwk)

】,欄位名【】別名【】";}}

return targetfields;

}

igeodbdatatransfer  介面用於乙個或多個資料集從乙個地理資料庫複製到另乙個地理資料庫。這包括**,要素類,要素資料集或任何其他型別的資料集以及包含不同型別資料集的集合

/// /// igeodbdatatransfer介面在兩個地理資料庫之間複製資料

///

/// key:自定義資料集名稱 value:資料集

///

private void datatransfer(dictionarydic,iworkspace targetws)

// 建立geodbdatatransfer物件和空名稱對映列舉器

igeodbdatatransfer geodbdatatransfer = new geodbdatatransferclass();

// 使用geodbdatatransfer物件建立名稱對映列舉器

//檢查是否有衝突

if (conflictsfound)}}

}}

// 迭代物件名稱並替換新名稱或配置關鍵字

////

// }

//}// start the transfer.

}

200000資料 33欄位

ifeaturebuffer

ifeaturedataconverter

igeodbdatatransfer

gdb--gdb

25342ms

24503ms

28347ms

gdb--mdb

125321ms

180722ms

139120ms

gdb--shp

27969ms

54444ms

不支援mdb--mdb

149751ms

154715ms

172766ms

mdb--gdb

22146ms

34357ms

33599ms

mdb--shp

29098ms

73460ms

不支援shp--shp

36052ms

51370ms

不支援shp--gdb

27021ms

26758ms

不支援shp--mdb

176056ms

113833ms

不支援

mysql和oracle中轉換類函式

mysql轉換類函式 1 用於將資料從一種型別轉換為另外一種型別 1 date format 將日期轉換成字串 按照指定格式轉換 select date format now y年 m月 d日 2 str to date 將日期格式的字串 轉換成指定格式的日期 日期格式解析 2 to number和...

Go語言中轉換JSON資料簡單例子

go語言轉換json資料真是非常的簡單。以easyui的demo為例,將 demo datagrid datagrid data1.json 拷貝到 gopath src目錄 json.go 複製 如下 package main import encoding json fmt io ioutil ...

Arduino 傳輸資料型別轉換

itoa 將整型值轉換為字串。ltoa 將長整型值轉換為字串。ultoa 將無符號長整型值轉換為字串。gcvt 將浮點型數轉換為字串,取四捨五入。ecvt 將雙精度浮點型值轉換為字串,轉換結果中不包含十進位制小數點。fcvt 指定位數為轉換精度,其餘同ecvt atof 將字串轉換為雙精度浮點型值。...