您现在的位置: 爱51代码网 >> 范文 >> 文章正文
gis如何将shp文件中部分数据另存为一个新的shp文件

比如,将某一shp文件中面积大于某值的图斑查找出,然后另存为一个新的shp文件
procedure ConvertFeatureClassToShapesFile(pFeatureClass: IFeatureClass; pFilePath, pFileName: string);
var
  pInDataSet, pOutDataSet: IDataSet;
  pInWorkSpace: IWorkSpace;
  pInFeatureClassName, pOutFeatureClassName: IFeatureClassName;
  pOutWorkspaceFactory: IWorkspaceFactory;
  pOutWorkerspace: IFeatureWorkspace;
  pOutWorkspaceName: IWorkspaceName;
  pOutDataSetName: IDatasetName;
  pFieldChecker: IFieldChecker;
  pEnumFieldError: IEnumFieldError;
  pOutFields: IFields;
  pFeatureDataConvert: IFeatureDataConverter;
  pQueryFilter: IQueryFilter;
  pSpatialFilter: ISpatialFilter;

  pFeature: IFeature;
begin
  if pFeatureClass = nil then
  begin
    exit;
  end;
  //得到输入
  pInDataSet := pFeatureClass as IDataSet;
  pInWorkSpace := pInDataSet.Workspace;
  pInFeatureClassName := pInDataSet.FullName as IFeatureClassName;

  //定义输出
  pOutWorkspaceFactory := CoShapefileWorkspaceFactory.create as IWorkspaceFactory;
  pOutWorkerspace := pOutWorkspaceFactory.OpenFromFile(pFilePath, 0) as IFeatureWorkspace;
  pOutDataSet := pOutWorkerspace as IDataset;
  pOutWorkspaceName := pOutDataSet.FullName as IWorkspaceName;
  pOutFeatureClassName := coFeatureClassName.Create as IFeatureClassName;

  pOutDataSetName := pOutFeatureClassName as IDatasetName;
  pOutDataSetName.Name := pFileName;
  pOutDataSetName.WorkspaceName := pOutWorkspaceName;

  //检查字段
  pFieldChecker := coFieldChecker.Create as IFieldChecker;
  pFieldChecker.InputWorkspace := pInWorkSpace;
  pFieldChecker.ValidateWorkspace := pOutWorkerspace as IWorkspace;
  pFieldChecker.Validate(pFeatureClass.Fields, pEnumFieldError, pOutFields);

  //要素筛选
  pQueryFilter := coQueryFilter.Create as IQueryFilter;
  pQueryFilter.WhereClause := '';

  //转换输出
  pFeatureDataConvert := coFeatureDataConverter.Create as IFeatureDataConverter;
  pFeatureDataConvert.ConvertFeatureClass(pInFeatureClassName, pQueryFilter, nil, pOutFeatureClassName, nil,   pOutFields, '', 100, 0);
end;

  • 上一篇文章:

  • 下一篇文章: 没有了
  • 最新文章 热点文章 相关文章
    maven如何加自定义的包
    redhat 2.6 (santigo 5.6) vsftp
    shell如何实现自动填写操作执行下
    linux shell 文件配置sh:color:
    shell script语法一定要加path吗
    SecureCRT如何访问虚拟机vmWare中
    C#如何读取WINDOWS的放大系数
    cximge的图如何存入数据库并提取
    DBGRID控件显示查询结果文本类型
    TChart控件如何把表中右边的系列
    maven如何加自定义的包
    redhat 2.6 (santigo 5.6) vsftp
    shell如何实现自动填写操作执行下
    linux shell 文件配置sh:color:
    shell script语法一定要加path吗
    SecureCRT如何访问虚拟机vmWare中
    C#如何读取WINDOWS的放大系数
    cximge的图如何存入数据库并提取
    DBGRID控件显示查询结果文本类型
    TChart控件如何把表中右边的系列
    如何把Google卫星地图做成mx
    如何下载google earth指定区
    PortTunnel如何配置
    geoserver用tiff图片发布图层
    arcgis for android 沿线标注
    GIS用百度行政区域的经纬度直
    有没有能扣取地图数据的软件
    谷歌地图瓦片URL计算方法
    mapxtreme java如何添加比例
    MapX如何实现地物快速搜索
     



    设为首页 | 加入收藏 | 网站地图 | 友情链接 |