On 01/24/2018 02:06 PM, jorge.conr...@cptec.inpe.br wrote:

Hi,

I have some gridded 4Km satellite images. I don't have experience with Python. The size of my image is (9896,3298) and I use this to read

f = open('merg_2018011100_4km-pixel', "r")  # reopen the file

x = f.read()

print (x[0])


Hello,

What are you trying to accomplish? Do you want the first byte? Do you want data in a specific format (maybe a hex string like "FFABE6", etc)?

Also, when dealing with "binary" files, you may want to append a "b" to "r". Assuming you are using Python 2 (from your print):

    import binascii

    with open('merg_2018011100_4km-pixel', 'rb') as f:
        data = f.read()

    hex_data = binascii.hexlify(data)
    first_byte = hex_data[0:2]
    print first_byte

--
~ Jugurtha Hadjar,

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to