2012-01-17

2012-01-14

grass gis batch interpolation and statistics

This post continues the previous one. Using two loops I created a raster files for each month and made a text file with basic statistics about these raster files in it.

here`s the code - http://pastebin.com/RtXuaQKS

I was using "boolean" switches because if the script grows larger, sometimes it is unnecessary to do things multiple times. Such switches eliminates running unwanted code (yeah, commenting also works, but.. i hate commenting blocks).

In this example the challenge was to correctly make heading-monthName when statistics were generated. Using awk the month name was passed as a command line argument and written in the appending file before statistics were written.

grass gis batch rename

Usually I dont like to do similar things multiple times. Like file or any object renaming.
Current problem involves Grass GIS database binded to vector layer. multiple columns has name as ID which doesn`t give much sense what exactly is stored in the column. Yet I know, that I have 14 columns with name dbl_1, dbl_2 and so on till dbl_14. The first two represents coordinates, and other 12 - monthly values. I would like to rename existing ID representing names to month names.
For such manipulation I need an array with month names. Then it is possible to iterate through the loop and in each iteration rename exact column.
Example is here - http://pastebin.com/52fMqL9j

Firstly the month names are passed as a simple string delimited with semicol ";"
Secondly, the string is splitted creating an array echoing and pipelining created string to bash tr comand (translate)
And then comes a loop over an created array. Counter "i" starts from value=3 because in my case the first id which represents the first monthly value is dbl_3 and it represents an october
In the loop the iterator increments through pipeline to bc

2012-01-11

chart series isExists

Here are multiple approaches how to check if chart series exists in Visual Basic 2010 (.NET)
For me the best approach is to use error exception and try&catch method.
http://forums.asp.net/p/1609665/4778480.aspx/1?p=True&t=634619304634512242

2011-12-27

Is user given filename valid?

...and try & catch comes to help.

Code in pastebin - http://pastebin.com/HCsDFtUv

Shortly - the function tries to write file and if success, then it deletes it and returns True. Otherwise it returns False. The function could be extended by trying the writing in specified temporary folder.

Such method allows to avoid from using specific and complex regular expressions.

2011-12-22

dummy csv/xyz writer for latvians

Software (written in Visual Basic 2010, dependent of .NET framework)
http://failiem.lv/down.php?i=ntpoppd&n=xyzCreator.exe


the class code (in VB2010) -
http://pastebin.com/fDL3WUSY

Different countries has their own different regional settings. Sometimes it is very inconvenient when in spreadsheet function the decimal separator is comma (as in Latvia) but for programs you need dot as the decimal separator.
In this simple tool just copy columns, choose settings and save somewhere the file.

2011-12-07

Local max,min and slope count in python list.

Simple function written in python - local maximum and minimum count and slope count in the given 1D array (list). M-shaped function has two maximums (or better say - two ascending/upward numbers in row) and minimums (two descending/downward numbers in row), but Λ shaped- one for both. Sometimes it is needed to know exact count of such maximums or minimums, or both.