Showing posts with label KEA files. Show all posts
Showing posts with label KEA files. Show all posts

Sunday, 4 June 2017

Computer troubles and further updates to TaklowKernewek tools

My desktop computer is currently incapacitated, it has for the past day and a half been resizing a NTFS partition after I made the decision, after breaking my QGIS installation while attempting to upgrade it to 2.18, to go back to a dual-boot system rather than a Windows virtual machine running in Ubuntu. Meanwhile I had also broken my netbook because it crashed while trying to upgrade to Ubuntu 17.04. I fixed this by doing a reinstall from a bootable USB stick using the UbuntuMATE iso, formatting only the root partition leaving data in /home intact.

This shouldn't deter anyone from using QGIS, or Ubuntu, just that I was doing odd things with GDAL and kealib, making myself able to use multiband .kea files  in QGIS running with the system environment variables, but use conda to run RSGISLib in Python 3, and also conda to run the European Space Agency's SNAP toolbox to process Sentinel 2 images.
There was a resulting mismatch between different versions of GDAL which caused problems when I tried to update to QGIS 2.18, which failed due to conflicting dependencies, and then trying to revert to 2.14 also failed, so therefore QGIS no longer worked at all.
With my netbook, I had installed so much on it that the root partition was close to full and I think that was what started causing problems.

Fortunately all data is backed up on external drives.

However it is not so easy to do much mapping work on my netbook, although I do now have QGIS 2.18 installed on it, but I have done a bit more on TaklowKernewek, including making the netbook mode work for more of the apps, and developing the mathematics quiz app.

The netbook modes were modified to allow the corpus statistics app, and a couple of others to fit the screen of my netbook (EeePC 1005HA), by adjusting font sizes as well as some input/output box heights.
Inflecting the verb 'covhe' (in SWF Tradycyonal) - Cornish for 'remember'



Inflecting the verb 'covhe' (in SWF Tradycyonal) - Cornish for 'remember'


Basic translation memory using Skeul an Yeth 1 example sentences. The font size of three of the four buttons has been shrunk a little so that labels do not grow bigger than the box itself.

more of the output

some further output of the translation memory


word frequency table for words of 5 or more letters in 'Origo Mundi'. The font sizes are quite small to read to make sure that the boxes do not fall off the bottom of the screen.
The word frequency bar chart has been tweaked as to not use white as a colour, since matplotlib may not always outline the bars.

counting syllables


Transliterating from Kernewek Kemmyn to Standard Written Form. It is possible that goelann should instead go to goolan in SWF, it certainly did in 2008 SWF, and may still do so despite being a multisyllable word.

Mathematics Quiz app

A new difficulty level allow input numbers up to 100, and the GUI has been adjusted to work better on smaller screens (though further work on this may be needed).
The options radio buttons have been consolidated into one column in the GUI

The program now reports back the answer to the previous question that you gave if you were correct as well as if you were wrong. This still looks a little confusing since the question now in the upper box is the second question whereas the answer is for the first. If you get a question right, you get 1 point. The bonus for speed has been reduced compared to earlier versions, to get any speed bonus at all you need to answer within 10 seconds.

'Pur gales' allows the computer to choose numbers up to 100, in this version the addition and subtraction are shown as symbols, due to possible confusion with 'ha' internal to the number such as 'dew ha dew ugens' (42). 'tri ha dew ugens marnas dew ha dew ugens' might be interpreted as 43 - 2 + 40 = 81 rather than 43 - 42 = 1.

There is a need to make some further adjustments to the Tkinter GUI code since at present the widgets aren't filling the window after it is maximized.

Friday, 20 June 2014

A little Python script to convert your Landsat scenes to KEA format

Downloading all this Mars data is starting to fill up my hard disks, so one thing I decided to do was compress all the various Landsat images I have.

Here is a Python script that will convert all GeoTIFF files in the current directory to the KEA format, and create a new header for each *MTL.txt Landsat header that exists in the directory to refer to the .kea files, for the use of a program such as ARCSI.

Download link (Dropbox)

# David Trethewey 20-06-2014
#
# convert all .tif or .TIF files
# in the current directory to .kea files
# using GDAL
# Does not delete any TIF files
#
# Assumptions:
# the TIF files are in the current directory
# that this script is being run from
# GDAL is available with KEA support

# Modifies any Landsat header *MTL.txt files so that
# arcsi.py works if you have compressed the
# band .TIF files to .kea
# Does not overwrite original header
#
# imports
import os.path
import sys

def replaceGTIFF_kea(inputtext):
    outputtext = ""   
    for w in inputtext:
        w = w.replace("GEOTIFF","KEA")
        w = w.replace(".TIF",".kea")
        # this line should be unnecessary since Landsat MTL files use capital letters      
        # but just in case you have one that doesn't
        w = w.replace(".tif",".kea")
        outputtext += w
    return outputtext

# find all *.TIF files and *MTL.txt files in the current directory
directory = os.getcwd()
dirFileList = os.listdir(directory)
# print dirFileList
tifFileList = [f for f in dirFileList if ((f[-4:]=='.TIF')or(f[-4:]=='.tif'))]
MTLFileList = [f for f in dirFileList if (f[-7:]=='MTL.txt')]

#output format (GDAL code)
outFormat = 'KEA'

# run gdal_translate on all TIFs to convert to KEA
for t in tifFileList:
    gdaltranscmd = "gdal_translate -of "+outFormat+" "+t+" "+t[:-4]+".kea"
    print gdaltranscmd
    os.system(gdaltranscmd)

# create a new header file referring to .kea files rather than .TIF
for m in MTLFileList:
    inputtext = file(m).readlines()
    outputtext = replaceGTIFF_kea(inputtext)
    outputfilebase = m[:-4]
    outputfile = outputfilebase + "_kea.txt"
    out = file(outputfile,"w")
    out.write(outputtext)
    out.close()