91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

GDAL進行shapefile數據柵格化,將shapefile中第一個多邊形讀取出來柵格化,根據“ID”字段

資源截圖

代碼片段和文件信息

#include?
#include?“gdal_priv.h“
#include?“gdal_alg.h“
#include?“ogrsf_frmts.h“
#include?“ogr_core.h“

using?namespace?std;
int?main()
{
GDALAllRegister();??
????OGRRegisterAll();??
?????
????OGRDataSource??*poDS;?????????
????char*?shpName;
????shpName?=?“..\\testRes\\SW_UTM.shp“;
????poDS?=?OGRSFDriverRegistrar::Open(shpName?FALSE?);??
????if(?poDS?==?NULL?)??
????{??
????????cout<<“Open?“<????????return?0;??
????????
????}?????????
????OGRlayer*?polayer;????
????polayer?=?poDS->Getlayer(0);???
????OGRFeature?*?poFeature?=?polayer->GetFeature(0);
????OGRGeometry?*?poGeometry?=?poFeature->GetGeometryRef();
????const?char?*?pszOutFileName?=?“.\\src2_out.tif“;??
????char?*?pszProjection;??
????OGRSpatialReference?*?poSRS?=?polayer->GetSpatialRef();??
????OGREnvelope??psExtent;??
????poGeometry->getEnvelope(&psExtent);??
????int?m_nImageWidth?=?(int)((psExtent.MaxX?-?psExtent.MinX)/500.0+0.5);
????int?m_nImageHeight?=(int)((psExtent.MaxY?-?psExtent.MinY)/500.0+0.5);
????if?(?!poSRS?)??
????{??
????????cout<<“Can‘t?open?the?“<????????m_nImageWidth?=?psExtent.MaxX;??
????????m_nImageHeight?=?psExtent.MaxY;
????}??
????else??
????{??
????????poSRS->exportToWkt(?&pszProjection?);??
??
????}??
??
??????
????const?char?*pszFormat?=?“GTiff“;??
????GDALDriver?*poDriver;??
????poDriver?=?GetGDALDriverManager()->GetDriverByName(pszFormat);?????????

????GDALDataset?*poNewDS?=?poDriver->Create(?pszOutFileName?m_nImageWidthm_nImageHeight1?GDT_Byte??NULL?);?????
????if?(?!poSRS?)??
????{??
????????double?adfGeoTransform[6];??
????????adfGeoTransform[0]?=?psExtent.MinX;??
????????adfGeoTransform[1]?=?500.0;??
????????adfGeoTransform[2]?=?0;??
????????adfGeoTransform[3]?=?psExtent.MaxY;??
????????adfGeoTransform[4]?=?0;??
????????adfGeoTransform[5]?=?-500.0;????????????????
????????GDALSetGeoTransform(?poNewDS?adfGeoTransform?);??
?????? OGRSpatialReference?*?poOGRSR?=?NULL;???
?????? poOGRSR->SetUTM(50);???
?????? poSRS->exportToWkt(&pszProjection);???
????????poNewDS->SetProjection(pszProjection);?????????
??
??

評論

共有 條評論