Last active
January 27, 2019 01:49
-
-
Save refactor/614d79911296cf42ca7d021536676ae2 to your computer and use it in GitHub Desktop.
Revisions
-
refactor revised this gist
Jan 27, 2019 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,9 @@ #include <ogr_srs_api.h> #include <gdalwarper.h> /* * https://www.gdal.org/warptut.html */ int main() { GDALAllRegister(); -
refactor revised this gist
Jan 20, 2019 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,13 +22,15 @@ int main() 0.0, NULL); // save as xml file, just for edit the VRT as a xml file, GDALDriverH hDriver = GDALGetDatasetDriver(hDstDS); GDALDatasetH hOutDS = GDALCreateCopy(hDriver, "my-dem.vrt", hDstDS, FALSE, NULL, NULL, NULL); GDALClose(hOutDS); // do the work with hDstDS, as the warp VRT dataset, // ... CPLFree(pszDstWKT); GDALClose( hDstDS ); GDALClose( hSrcDS ); -
refactor revised this gist
Jan 20, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,7 @@ int main() OSRImportFromEPSG(dstSRS, 3857); char *pszDstWKT = NULL; OSRExportToWkt(dstSRS, &pszDstWKT); OSRDestroySpatialReference(dstSRS); printf("pass...\r\n%s\r\n", pszDstWKT); GDALDatasetH hDstDS = GDALAutoCreateWarpedVRT(hSrcDS, -
refactor revised this gist
Jan 20, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ int main() { GDALAllRegister(); // Open input and output files. GDALDatasetH hSrcDS = GDALOpenShared( "cq-dem.tif", GA_ReadOnly ); OGRSpatialReferenceH dstSRS = OSRNewSpatialReference(NULL); -
refactor revised this gist
Jan 20, 2019 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,10 +21,10 @@ int main() 0.0, NULL); GDALDriverH hDriver = GDALGetDatasetDriver(hDstDS); GDALDatasetH hOutDS = GDALCreateCopy(hDriver, "my-dem.vrt", hDstDS, FALSE, NULL, NULL, NULL); GDALClose(hOutDS); -
refactor revised this gist
Jan 20, 2019 . No changes.There are no files selected for viewing
-
refactor renamed this gist
Jan 20, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
refactor revised this gist
Jan 20, 2019 . 1 changed file with 24 additions and 27 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,39 +1,36 @@ #include <cpl_conv.h> #include <ogr_srs_api.h> #include <gdalwarper.h> int main() { // Open input and output files. GDALAllRegister(); GDALDatasetH hSrcDS = GDALOpenShared( "cq-dem.tif", GA_ReadOnly ); OGRSpatialReferenceH dstSRS = OSRNewSpatialReference(NULL); OSRImportFromEPSG(dstSRS, 3857); char *pszDstWKT = NULL; OSRExportToWkt(dstSRS, &pszDstWKT); printf("pass...\r\n%s\r\n", pszDstWKT); GDALDatasetH hDstDS = GDALAutoCreateWarpedVRT(hSrcDS, GDALGetProjectionRef(hSrcDS), pszDstWKT, GRA_NearestNeighbour, 0.0, NULL); // GDALGetMetadata(hDstDS, GDALDriverH hDriver = GDALGetDatasetDriver(hDstDS); GDALDatasetH hOutDS = GDALCreateCopy(hDriver, "my-dem.vrt", hDstDS, FALSE, NULL, NULL, NULL); GDALClose(hOutDS); CPLFree(pszDstWKT); GDALClose( hDstDS ); GDALClose( hSrcDS ); return 0; } -
refactor created this gist
Jan 20, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #include <cpl_conv.h> #include <gdalwarper.h> int main() { // Open input and output files. GDALAllRegister(); GDALDatasetH hSrcDS = GDALOpen( "cq-dem.tif", GA_ReadOnly ); GDALDatasetH hDstDS = GDALOpen( "out.tif", GA_Update ); // Setup warp options. GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions(); psWarpOptions->hSrcDS = hSrcDS; psWarpOptions->hDstDS = hDstDS; psWarpOptions->nBandCount = 1; psWarpOptions->panSrcBands = (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount ); psWarpOptions->panSrcBands[0] = 1; psWarpOptions->panDstBands = (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount ); psWarpOptions->panDstBands[0] = 1; psWarpOptions->pfnProgress = GDALTermProgress; // Establish reprojection transformer. psWarpOptions->pTransformerArg = GDALCreateGenImgProjTransformer( hSrcDS, GDALGetProjectionRef(hSrcDS), hDstDS, GDALGetProjectionRef(hDstDS), FALSE, 0.0, 1 ); psWarpOptions->pfnTransformer = GDALGenImgProjTransform; // Initialize and execute the warp operation. GDALWarpOperationH hOperation = GDALCreateWarpOperation( psWarpOptions ); GDALChunkAndWarpImage(hOperation, 0, 0, GDALGetRasterXSize( hDstDS ), GDALGetRasterYSize( hDstDS ) ); GDALDestroyGenImgProjTransformer( psWarpOptions->pTransformerArg ); GDALDestroyWarpOptions( psWarpOptions ); GDALClose( hDstDS ); GDALClose( hSrcDS ); return 0; }