0

I am trying to make raster file from a shapefile. I am trying to use GDALRasterize() function for it. But it is not recognizing GDALRasterize function ('GDALRasterize' was not declared in this scope). But I have included GDAL.h, cpl_port.h.

#include <stdio.h>
#include <stdlib.h>
#include <gdal.h>
#include <cpl_conv.h>
#include <cpl_port.h>

//main function
int main()
{   
char path1[200],path2[200],filename1[]="/inRasters/line.tif",filename2[]="/in_shapes/line.shp";
GDALDatasetH lineDS,lineDS_shp;

GDALAllRegister();

getcwd(path1, sizeof(path1));
strcpy(path2,path1);
strcat(path1,filename1);
strcat(path2,filename2);

lineDS_shp = GDALOpenEx(path2, GDAL_OF_VECTOR, NULL, NULL, NULL );
lineDS = GDALRasterize(path1,NULL,lineDS_shp,NULL,NULL);    

GDALClose(lineDS_shp);
GDALClose(lineDS);
return 0;
}
0

GDALRasterize defined in gdal_utils.h See usage here: https://svn.osgeo.org/gdal/trunk/gdal/apps/gdal_rasterize_bin.cpp

since GDAL 2.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.