Last active
January 27, 2019 01:49
-
-
Save refactor/614d79911296cf42ca7d021536676ae2 to your computer and use it in GitHub Desktop.
test GDALAutoCreateWarpedVRT
This file contains 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 characters
#include <cpl_conv.h> | |
#include <ogr_srs_api.h> | |
#include <gdalwarper.h> | |
/* | |
* https://www.gdal.org/warptut.html | |
*/ | |
int main() | |
{ | |
GDALAllRegister(); | |
// Open input and output files. | |
GDALDatasetH hSrcDS = GDALOpenShared( "cq-dem.tif", GA_ReadOnly ); | |
OGRSpatialReferenceH dstSRS = OSRNewSpatialReference(NULL); | |
OSRImportFromEPSG(dstSRS, 3857); | |
char *pszDstWKT = NULL; | |
OSRExportToWkt(dstSRS, &pszDstWKT); | |
OSRDestroySpatialReference(dstSRS); | |
printf("pass...\r\n%s\r\n", pszDstWKT); | |
GDALDatasetH hDstDS = GDALAutoCreateWarpedVRT(hSrcDS, | |
GDALGetProjectionRef(hSrcDS), pszDstWKT, | |
GRA_NearestNeighbour, | |
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 ); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gcc
gdal-config --cflags
warp_test.cgdal-config --libs