【GDAL】C++加载矢量数据
【GDAL】C++加载矢量数据 注意事项: 1、加载和保存shp都需要的准备工作代码段: CPLSetConfigOption ( "GDAL_FILENAME_IS_UTF8" , "NO" ) ; // 支持中文路径 CPLSetConfigOption ( "SHAPE_ENCODING" , "" ) ; //属性表支持中文字段 GDALAllRegister ( ) ; 2、读shp:获得feature 的所需要用到的接口: GDALDataset OGRlayer、OGRFeatureDefn等。 关键代码: GDALDataset * podataset = ( GDALDataset * ) GDALOpenEx ( file_path_name , GDAL_OF_VECTOR , NULL , NULL , NULL ) ; if ( podataset == NULL ) { cout << "open failed." << endl ; return 0 ; } int layercount = podataset - > GetLayerCount ( ) ; OGRLayer * player = podataset - > GetLayer ( 0 ) ; OGRFeatureDefn * pDefn = player - >