Geoprocessing 数据批处理

 

ArcGIS使用者经常要面对大量的数据处理工作,如果要在自己的程序中使用Geoprocessing,更多的时候我们是要进行对数据进行批处理分析,Geoprocessing为我们提供了丰富的支持批处理的功能。

1.工作空间中查询所需数据

2.模型处理过程中各种输入、环境参数、字段映射的处理

3.枚举、循环执行

--------------------

1.工作空间中查询所需数据

    要对数据进行批处理操作,首先需要知道工作空间中有哪些数据,怎么从工作空间大量数据中提取出我们所需要的数据。GeoProcessor类为我们提供了一些提取数据的方法。

listDatasets (string wildCard, string datasetType)
listFeatureClasses (string wildCard, string featureType, string dataset)
listRasters (string wildCard, string rasterType)
listTables (string wildCard, string tableType)
listToolboxes(string wildCard)
listWorkspaces (string wildCard, string workspaceType)

    看看代码段怎么写:

//list all the featureClasses starting with c
gp.setEnvironmentValue("workspace", inputWorkspace);
IGpEnumList featureClasses = gp.listFeatureClasses("c*", "", "");

String featureClass = featureClasses.next();

System.out.println("-----------Feature Classes starting with c-----------");

while (! "".equals(featureClass)) {
     System.out.println(featureClass);

     featureClass = featureClasses.next();

}

    通过指定wildCard字符串,搜索所有"c"开头的feature class,将结果存放在com.esri.arcgis.geoprocessing.IGpEnumList枚举List中。看到IGpEnumList千万不要将它和Java数据结构中各种List相提并论,它仅仅具有顺序枚举next和重置查询指针reset的功能,可以被序列化。

    再参考另外两个例子,相信对在工作空间中查询数据会有更多的认识。

    返回所有面状要素

System.out.println(""n-----------Polygon Feature Classes-----------");
gp.setEnvironmentValue("workspace", inputWorkspace);

featureClasses = gp.listFeatureClasses("", "polygon", "");
featureClass = featureClasses.next();

    
while (! "".equals(featureClass)) {            (GIS|RS|GPS) ] h6h8SW‑m MQl o
    System.out.println(featureClass);
    featureClass = featureClasses.next();

}

    返回所有TIF格式的Raster数据

// List all TIF files in the workspace and build pyramids
gp.setEnvironmentValue("workspace", inputWorkspace);
IGpEnumList rasters = gp.listRasters("", "TIF");
String raster = rasters.next();
(GIS|RS|GPS)
Rl Qg7} pe ~

                  
BuildPyramids buildPyramids = 
new BuildPyramids(raster);
while (! "".equals(raster)) {
    System.out.println(""n------------Building pyramids for: " + raster + "----------");

    gp.execute(buildPyramids, 
null);(GIS|RS|GPS)r };Cc9[_ M
    raster = rasters.next();
}

    关于各种list方法TYPE类型,可以参考下表
Y
Z5n­B,p b
Yo l0

Method

Type Keywords

ListDatasets

All, Feature, Coverage, RasterCatalog, CAD, VPF, TIN, Topology

ListFeatureClasses

All, Point, Label, Node, Line, Arc, Route, Polygon, Region

ListFields

All, SmallInteger, Integer, Single, Double, String, Date, OID, Geometry, Blob

ListWorkspaces

All, Coverage, Access, SDE, Folder

ListTables

All, dBASE, INFO

ListRasters 

All, ADRG, BIL, BIP, BSQ, BMP, CADRG, CIB, ERS, GIF, GIS, GRID, STACK, IMG, JPEG, LAN, SID, SDE, TIF, RAW, PNG, NITF


2.模型处理过程中各种输入、环境参数的处理

    Geoprocessing计算过程中会要求多个输入,通常可以用IGpEnumList来捕获。

gp.setEnvironmentValue("workspace", multiWorkspace);RB‑DG/P i+Sy
IGpEnumList polygonFCs = gp.listFeatureClasses("", "polygon", "");
(GIS|RS|GPS) W I/ya2?N eur? Tc
String polygon = polygonFCs.next();
String polygonsToUnion = "";
(GIS|RS|GPS),upT*? n]'g r
while (! "".equals(polygon)){
}0I!O Y$ju0  polygonsToUnion += polygon;
 polygon = polygonFCs.next();
*{.r n x#{`+K$"0  if (! "".equals(polygon)){
  polygonsToUnion += ";";
X J,mf(}I
 }

}

    
Union union = 
new Union(polygonsToUnion,outputWorkspace+"/unioned.shp");
gp.execute(union, 
null);

    另外,可以使用表结构来保存每个输入的参数值,避免全部feature保存在一个字符串中。

// List all feature classes in the workspace.
gp.setEnvironmentValue("workspace", multiWorkspace);
t.D8n J1u"0[V0 IGpEnumList polygonFCs = gp.listFeatureClasses("", "polygon", "");
   
W Hb#kz K
//make the value table
GPValueTable gpValueTable = new GPValueTable();
  

String polygon = polygonFCs.next();
(GIS|RS|GPS)']X_e+N W)[&TS
String row = 
null;[
while (! "".equals(polygon)){
"R l8R1L U)T0  
if ("center".equals(polygon)){     (GIS|RS|GPS) i(W&? ?
d^ }/Bg%e"D!~j)n

     row = polygon + " 1";     
 } 
else {
_DL6"&yB1D,M hgeM+G!o0      row = polygon + " 2";
XP6nJ!g i+Hz
y0  }      
­t'H` A ~pG/v0  gpValueTable.addRow(row);
 polygon = polygonFCs.next();
 }
      
(GIS|RS|GPS);Xm F b;F3CK"? R
Union union = 
new Union(gpValueTable, outputWorkspace+"/unionedValueTable.shp");
gp.execute(union, 
null);

3.枚举、循环执行

    前面两点都是针对一个 Geoprocessing 操作而言,如果需要多个操作,可以用基本程序语言来描述,这分为两种情况,一是多种 Geoprocessing 的数据处理,一种是同一 Geoprocessing 循环执行,相比 ArcToolbox 而言,这里体现的是程序代码带给我们的方便。

转载于:https://www.cnblogs.com/njlhb/archive/2008/01/17/1043649.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值