I'm trying to use GDAL using C++ but I get NULL always when I try to open a WFS server for getting the data set

  const char *pszFilename = "http://demo.opengeo.org/geoserver/wfs";

    GDALDataset  *poDataset;    GDALAllRegister();    
    poDataset = (GDALDataset *)GDALOpen(pszFilename, GA_ReadOnly);    

1 Answer 1


Actually i am not familiar with the WFS server,but looking in to the code the pointer variable *pszFilename is assigned to the URL of your server. In your URL you must also include the vector or the raster file that you want to open. And you must have that vector file or raster file in your URL directory.

for example for simple non server console application using visual studio if you have a shape file name city.shp then to open this file first you have to copy and past the file city.shp and all its contents in to your visual stdio project directory.

the modifying the code as follow and compiling it will works.

const char *pszFilename = "city.shp";
GDALDataset  *poDataset;    
poDataset = (GDALDataset *)GDALOpen(pszFilename, GA_ReadOnly);  
       cout<<"the file you want to open is not find"<<endl;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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