Re: [Ubuntu] cpp and python codes not able to access gdal library
Angelos, Adding the following to the code works... sys.path.insert(0,"/usr/lib/python2.7/dist-packages") is there any other way to avoid adding this line? Regards, Alassane On Mon, Oct 24, 2016 at 9:03 AM, Angelos Tzotsos wrote: > Hi, > > Sorry for the delayed response. > Is this issue still open? > > Best, > Angelos > > > On 10/14/2016 03:23 PM, alassane toure wrote: > >> Not sure how to obtain the installed version for python-gdal but here is >> how i installed it (if that can help) >> >> sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable >> sudo apt-get update >> sudo apt-get install python-gdal >> >> Thanks for your suggestions >> >> Alassane >> >> On Fri, Oct 14, 2016 at 8:16 AM, alassane toure >> wrote: >> >> GDAL is 1.11.2 as I had other issues with 2.1.0. and python-gdal has to be >>> the most recent one. I will let you know as soon i get on the server. >>> >>> Thanks. >>> >>> Alassane >>> >>> On Fri, Oct 14, 2016 at 4:28 AM, Angelos Tzotsos >>> wrote: >>> >>> Hi, Can you please list the versions of libgdal and python-gdal that are installed on your machine? Best, Angelos On 10/14/2016 06:41 AM, alassane toure wrote: Even, I tried the followings but the response did not change... sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable sudo apt-get update sudo apt-get install python-gdal Any suggestions? Thanks, Alassane On Thu, Sep 8, 2016 at 3:51 AM, Even Rouault < even.roua...@spatialys.com> wrote: Alassane, I developed a gdal code on my local machine and it worked. Having gdal and g++ working on the server my compilation of the same code resulted in the following response... gcc -o applymask applymask.cpp -I /usr/include/gdal -lgdal -lm applymask.cpp: In function âint main(int, char**)â: applymask.cpp:63:95: warning: ignoring return value of âCPLErr GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with attribute warn_unused_result [-Wunused-result] Band->RasterIO( GF_Read, 0, iLine,nXSize, 1, inScanline, nXSize, 1, GDT_Float32,0, 0 ); ^ applymask.cpp:64:101: warning: ignoring return value of âCPLErr GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with attribute warn_unused_result [-Wunused-result] maskBand->RasterIO( GF_Read, 0, iLine,nXSize, 1, maskScanline, nXSize, 1, GDT_Float32,0, 0 ); ^ applymask.cpp:75:94: warning: ignoring return value of âCPLErr GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with attribute warn_unused_result [-Wunused-result] outBand->RasterIO( GF_Write, 0, iLine,nXSize, 1, outScanline, nXSize, 1, GDT_Float32,0, 0 ); The warning says it all. You use GDALRasterBand::RasterIO() but do not check the return value. You probably don't get it on your local machine since it might use an older version of GDAL where this method wasn't tagged with the warn_unused_result attribute. The right fix is to check the return value and do something appropriate. Or you can silence the warning by enclosing the calls in CPL_IGNORE_RET_VAL(...) Also, my python code does not import all refered libraries including gdal. File "/usr/local/bin/CD4DEM.py", line 12, in import gdalImportError: No module named gdal Did you install the python-gdal package ? Even -- Spatialys - Geospatial professional serviceshttp://www.spatialys.com ___ UbuntuGIS mailing listUbuntu@lists.osgeo.orghttp:// lists.osgeo.org/mailman/listinfo/ubuntuhttp://trac. osgeo.org/ubuntugis/wiki -- Angelos Tzotsos, PhD OSGeo Charter Memberhttp://users.ntua.gr/tzotsos > > -- > Angelos Tzotsos, PhD > OSGeo Charter Member > http://users.ntua.gr/tzotsos > > ___ UbuntuGIS mailing list Ubuntu@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/ubuntu http://trac.osgeo.org/ubuntugis/wiki
Re: [Ubuntu] cpp and python codes not able to access gdal library
GDAL is 1.11.2 as I had other issues with 2.1.0. and python-gdal has to be the most recent one. I will let you know as soon i get on the server. Thanks. Alassane On Fri, Oct 14, 2016 at 4:28 AM, Angelos Tzotsos wrote: > Hi, > > Can you please list the versions of libgdal and python-gdal that are > installed on your machine? > > Best, > Angelos > > > On 10/14/2016 06:41 AM, alassane toure wrote: > > Even, > > I tried the followings but the response did not change... > > sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable > sudo apt-get update > sudo apt-get install python-gdal > > Any suggestions? > Thanks, > Alassane > > On Thu, Sep 8, 2016 at 3:51 AM, Even Rouault > > wrote: > > > Alassane, > > > I developed a gdal code on my local machine and it worked. Having gdal > > and > > g++ working on the server my compilation of the same code resulted in the > following response... > > gcc -o applymask applymask.cpp -I /usr/include/gdal -lgdal -lm > applymask.cpp: In function âint main(int, char**)â: > applymask.cpp:63:95: warning: ignoring return value of âCPLErr > GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, > > int, > > GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with > attribute warn_unused_result [-Wunused-result] > Band->RasterIO( GF_Read, 0, iLine,nXSize, 1, inScanline, nXSize, > 1, GDT_Float32,0, 0 ); > >^ > applymask.cpp:64:101: warning: ignoring return value of âCPLErr > GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, > > int, > > GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with > attribute warn_unused_result [-Wunused-result] > maskBand->RasterIO( GF_Read, 0, iLine,nXSize, 1, maskScanline, > nXSize, 1, GDT_Float32,0, 0 ); > > ^ > applymask.cpp:75:94: warning: ignoring return value of âCPLErr > GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, > > int, > > GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with > attribute warn_unused_result [-Wunused-result] >outBand->RasterIO( GF_Write, 0, iLine,nXSize, 1, outScanline, nXSize, > > 1, > > GDT_Float32,0, 0 ); > > > The warning says it all. You use GDALRasterBand::RasterIO() but do not > check > the return value. You probably don't get it on your local machine since it > might use an older version of GDAL where this method wasn't tagged with the > warn_unused_result attribute. > > The right fix is to check the return value and do something appropriate. > Or you > can silence the warning by enclosing the calls in CPL_IGNORE_RET_VAL(...) > > > Also, my python code does not import all refered libraries including > > gdal. > > File "/usr/local/bin/CD4DEM.py", line 12, in > import gdalImportError: No module named gdal > > Did you install the python-gdal package ? > > Even > > -- > Spatialys - Geospatial professional serviceshttp://www.spatialys.com > > > > ___ > UbuntuGIS mailing > listUbuntu@lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/ubuntuhttp://trac.osgeo.org/ubuntugis/wiki > > > > -- > Angelos Tzotsos, PhD > OSGeo Charter Memberhttp://users.ntua.gr/tzotsos > > ___ UbuntuGIS mailing list Ubuntu@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/ubuntu http://trac.osgeo.org/ubuntugis/wiki
Re: [Ubuntu] cpp and python codes not able to access gdal library
Hi, Can you please list the versions of libgdal and python-gdal that are installed on your machine? Best, Angelos On 10/14/2016 06:41 AM, alassane toure wrote: Even, I tried the followings but the response did not change... sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable sudo apt-get update sudo apt-get install python-gdal Any suggestions? Thanks, Alassane On Thu, Sep 8, 2016 at 3:51 AM, Even Rouault wrote: Alassane, I developed a gdal code on my local machine and it worked. Having gdal and g++ working on the server my compilation of the same code resulted in the following response... gcc -o applymask applymask.cpp -I /usr/include/gdal -lgdal -lm applymask.cpp: In function âint main(int, char**)â: applymask.cpp:63:95: warning: ignoring return value of âCPLErr GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with attribute warn_unused_result [-Wunused-result] Band->RasterIO( GF_Read, 0, iLine,nXSize, 1, inScanline, nXSize, 1, GDT_Float32,0, 0 ); ^ applymask.cpp:64:101: warning: ignoring return value of âCPLErr GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with attribute warn_unused_result [-Wunused-result] maskBand->RasterIO( GF_Read, 0, iLine,nXSize, 1, maskScanline, nXSize, 1, GDT_Float32,0, 0 ); ^ applymask.cpp:75:94: warning: ignoring return value of âCPLErr GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with attribute warn_unused_result [-Wunused-result] outBand->RasterIO( GF_Write, 0, iLine,nXSize, 1, outScanline, nXSize, 1, GDT_Float32,0, 0 ); The warning says it all. You use GDALRasterBand::RasterIO() but do not check the return value. You probably don't get it on your local machine since it might use an older version of GDAL where this method wasn't tagged with the warn_unused_result attribute. The right fix is to check the return value and do something appropriate. Or you can silence the warning by enclosing the calls in CPL_IGNORE_RET_VAL(...) Also, my python code does not import all refered libraries including gdal. File "/usr/local/bin/CD4DEM.py", line 12, in import gdalImportError: No module named gdal Did you install the python-gdal package ? Even -- Spatialys - Geospatial professional services http://www.spatialys.com ___ UbuntuGIS mailing list Ubuntu@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/ubuntu http://trac.osgeo.org/ubuntugis/wiki -- Angelos Tzotsos, PhD OSGeo Charter Member http://users.ntua.gr/tzotsos ___ UbuntuGIS mailing list Ubuntu@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/ubuntu http://trac.osgeo.org/ubuntugis/wiki
Re: [Ubuntu] cpp and python codes not able to access gdal library
Even, I tried the followings but the response did not change... sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable sudo apt-get update sudo apt-get install python-gdal Any suggestions? Thanks, Alassane On Thu, Sep 8, 2016 at 3:51 AM, Even Rouault wrote: > Alassane, > > > I developed a gdal code on my local machine and it worked. Having gdal > and > > g++ working on the server my compilation of the same code resulted in the > > following response... > > > > gcc -o applymask applymask.cpp -I /usr/include/gdal -lgdal -lm > > applymask.cpp: In function âint main(int, char**)â: > > applymask.cpp:63:95: warning: ignoring return value of âCPLErr > > GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, > int, > > GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with > > attribute warn_unused_result [-Wunused-result] > > Band->RasterIO( GF_Read, 0, iLine,nXSize, 1, inScanline, nXSize, > > 1, GDT_Float32,0, 0 ); > > > >^ > > applymask.cpp:64:101: warning: ignoring return value of âCPLErr > > GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, > int, > > GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with > > attribute warn_unused_result [-Wunused-result] > > maskBand->RasterIO( GF_Read, 0, iLine,nXSize, 1, maskScanline, > > nXSize, 1, GDT_Float32,0, 0 ); > > > > ^ > > applymask.cpp:75:94: warning: ignoring return value of âCPLErr > > GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, > int, > > GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with > > attribute warn_unused_result [-Wunused-result] > >outBand->RasterIO( GF_Write, 0, iLine,nXSize, 1, outScanline, nXSize, > 1, > > GDT_Float32,0, 0 ); > > > > The warning says it all. You use GDALRasterBand::RasterIO() but do not > check > the return value. You probably don't get it on your local machine since it > might use an older version of GDAL where this method wasn't tagged with the > warn_unused_result attribute. > > The right fix is to check the return value and do something appropriate. > Or you > can silence the warning by enclosing the calls in CPL_IGNORE_RET_VAL(...) > > > > > Also, my python code does not import all refered libraries including > gdal. > > > > File "/usr/local/bin/CD4DEM.py", line 12, in > > import gdalImportError: No module named gdal > > Did you install the python-gdal package ? > > Even > > -- > Spatialys - Geospatial professional services > http://www.spatialys.com > ___ UbuntuGIS mailing list Ubuntu@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/ubuntu http://trac.osgeo.org/ubuntugis/wiki
Re: [Ubuntu] cpp and python codes not able to access gdal library
Alassane, > I developed a gdal code on my local machine and it worked. Having gdal and > g++ working on the server my compilation of the same code resulted in the > following response... > > gcc -o applymask applymask.cpp -I /usr/include/gdal -lgdal -lm > applymask.cpp: In function âint main(int, char**)â: > applymask.cpp:63:95: warning: ignoring return value of âCPLErr > GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, > GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with > attribute warn_unused_result [-Wunused-result] > Band->RasterIO( GF_Read, 0, iLine,nXSize, 1, inScanline, nXSize, > 1, GDT_Float32,0, 0 ); > >^ > applymask.cpp:64:101: warning: ignoring return value of âCPLErr > GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, > GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with > attribute warn_unused_result [-Wunused-result] > maskBand->RasterIO( GF_Read, 0, iLine,nXSize, 1, maskScanline, > nXSize, 1, GDT_Float32,0, 0 ); > > ^ > applymask.cpp:75:94: warning: ignoring return value of âCPLErr > GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, > GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg*)â, declared with > attribute warn_unused_result [-Wunused-result] >outBand->RasterIO( GF_Write, 0, iLine,nXSize, 1, outScanline, nXSize, 1, > GDT_Float32,0, 0 ); > The warning says it all. You use GDALRasterBand::RasterIO() but do not check the return value. You probably don't get it on your local machine since it might use an older version of GDAL where this method wasn't tagged with the warn_unused_result attribute. The right fix is to check the return value and do something appropriate. Or you can silence the warning by enclosing the calls in CPL_IGNORE_RET_VAL(...) > > Also, my python code does not import all refered libraries including gdal. > > File "/usr/local/bin/CD4DEM.py", line 12, in > import gdalImportError: No module named gdal Did you install the python-gdal package ? Even -- Spatialys - Geospatial professional services http://www.spatialys.com ___ UbuntuGIS mailing list Ubuntu@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/ubuntu http://trac.osgeo.org/ubuntugis/wiki