Re: [GRASS-user] Retrieve pixel resolution using Python, Script
Thanks Eloi but this only gives me the number of pixels (number of lines and columns) not the pixel resolution. Is there a retrieve this information in a Python script (e.g. using python GDAL)? Thanks Antonio __ Information from ESET NOD32 Antivirus, version of virus signature database 5236 (20100629) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Retrieve pixel resolution using Python Script
Hello Mark I know that I can retrieve that information with gdalinfo. But I need to have it on a variable and get/use it in a Python Script. Mark Seibel wrote: If you use gdalinfo on an image, it will output the "Pixel Size". Hope that helps. Mark 2010/6/28 António Rocha : Greetings I'm trying to retrieve an image (not yet imported to GRASS) pixel resolution through a Python Script but so far i was unable to figure out a method to do this. Is this possible? I have used g.proj to retrieve its projection and datum but not the Pixel resolution. THanks for your help Best regards, Antonio R. __ Information from ESET NOD32 Antivirus, version of virus signature database 5234 (20100628) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user __ Information from ESET NOD32 Antivirus, version of virus signature database 5234 (20100628) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5235 (20100628) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Retrieve pixel resolution using Python Script
Olá António Rocha, This works for me, give it a try: ### import os try: from osgeo import gdal from osgeo import osr except: import gdal import osr def gdalinfo(pasta): '''Le metadados com GDAL''' ficheiros = os.listdir(pasta) for ficheiro in ficheiros: if ficheiro[-3:].lower() == 'tif': # abrir imagem filename = pasta+ficheiro dataset = gdal.Open(filename, gdal.GA_ReadOnly) if dataset is None: print 'Nao foi possivel abrir a imagem %s!' % ficheiro RasterXSize = dataset.RasterXSize RasterYSize = dataset.RasterYSize print RasterXSize,RasterYSize print '\nfim' return gdalinfo('/home/eloi/Geo/raster/20790/') ### 2010/6/28 Mark Seibel > If you use gdalinfo on an image, it will output the "Pixel Size". > > Hope that helps. > Mark > > 2010/6/28 António Rocha : > > Greetings > > > > I'm trying to retrieve an image (not yet imported to GRASS) pixel > resolution > > through a Python Script but so far i was unable to figure out a method to > do > > this. Is this possible? I have used g.proj to retrieve its projection and > > datum but not the Pixel resolution. > > THanks for your help > > > > Best regards, > > Antonio R. > > > > > > __ Information from ESET NOD32 Antivirus, version of virus > signature > > database 5234 (20100628) __ > > > > The message was checked by ESET NOD32 Antivirus. > > > > http://www.eset.com > > > > > > ___ > > grass-user mailing list > > grass-user@lists.osgeo.org > > http://lists.osgeo.org/mailman/listinfo/grass-user > > > ___ > grass-user mailing list > grass-user@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/grass-user > -- Eloi Ribeiro GIS Analyst 39,45º -4,40º http://eloiribeiro.wordpress.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Retrieve pixel resolution using Python Script
If you use gdalinfo on an image, it will output the "Pixel Size". Hope that helps. Mark 2010/6/28 António Rocha : > Greetings > > I'm trying to retrieve an image (not yet imported to GRASS) pixel resolution > through a Python Script but so far i was unable to figure out a method to do > this. Is this possible? I have used g.proj to retrieve its projection and > datum but not the Pixel resolution. > THanks for your help > > Best regards, > Antonio R. > > > __ Information from ESET NOD32 Antivirus, version of virus signature > database 5234 (20100628) __ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > > ___ > grass-user mailing list > grass-user@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/grass-user > ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Retrieve pixel resolution using Python Script
Greetings I'm trying to retrieve an image (not yet imported to GRASS) pixel resolution through a Python Script but so far i was unable to figure out a method to do this. Is this possible? I have used g.proj to retrieve its projection and datum but not the Pixel resolution. THanks for your help Best regards, Antonio R. __ Information from ESET NOD32 Antivirus, version of virus signature database 5234 (20100628) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user