Quantcast
Channel: Question and Answer » gdal
Viewing all articles
Browse latest Browse all 397

Load the raster image which is in TIF format using QGIS API

$
0
0

I am quite new inthe field of GIS.
I am interested in is to load the raster image which is in TIF format using QGIS API

I have followed the steps given the in the follwing link to load shape file
enter link description here
http://geospatialdesktop.com/2009/02/creating_a_standalone_gis_application_1/ and it works fine

To load the rester image i have followed the steps given int he link
http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/loadlayer.html

I have python 2.7.6 ,GDAL 1.10.1 installed with qgis2.0 installed in my system

code snippet

import osgeo.gdal
from  gdalconst import *
from PyQt4.QtCore import QFileInfo,QSettings
from qgis.core import QgsRasterLayer, QgsCoordinateReferenceSystem

file = QFileDialog.getOpenFileName(self, 
    "Open TIF Image", ".", "Tagged image (*.tif)")
fileInfo = QFileInfo(file)    
fileName=fileInfo.fileName()
baseName = fileInfo.baseName()

layer = QgsRasterLayer(fileName, baseName)    

but the image is not loaded and i got the following error in the terminal

ERROR 4: `mypic.tif' does not exist in the file system,
and is not recognised as a supported dataset name.

Layer failed to load!
QObject::connect: Cannot connect (null)::repaintRequested() to QgsMapCanvas::refresh()
QObject::connect: Cannot connect (null)::screenUpdateRequested() to QgsMapCanvas::updateMap()

Viewing all articles
Browse latest Browse all 397