2011-01-30

Python scripting under GRASS GIS

It was few months ago when I using GRASS last time. Since then there was few things that came in my mind about scripting. I discovered, that it was very easy building and launching bash scripts under windows environment, but I never tried Python.
Today, just accidentally, I was starting to think about it again, and discover, that it is not as easy as bashing, but very close.
The first thing was - install Python. In my case I was using Python 2.7.
The second - to set neccessary environmental variables.
And here comes where attention is needed.
In GRASS GIS homepage there are some samples using environmental variables, but it is possible, that user`s machine/computer is differentely configured.

So, here they are:


GISBASE= C:\GRASS-64
GISRC= C:\Documents and Settings\user\.grassrc6
LD_LIBRARY_PATH= C:\GRASS-64\lib
PATH= C:\GRASS-64\etc;C:\GRASS-64\etc\python;C:\GRASS-64\lib;C:\GRASS-64\bin;C:\GRASS-64\extralib;C:\GRASS-64\msys\bin;C:\Python26;
PYTHONLIB= C:\Python26
PYTHONPATH= C:\GRASS-64\etc\python
GRASS_SH= C:\GRASS-64\msys\bin\sh.exe


1st - Drive letter. In my case it`s D:\
2nd - user. Usually it is the name of user.
3rd - Where the GRASS is stored
4th - Where the Python is stored
5th - What version of Python is used.

That`s it.

2011-01-19

Getting categories out of blogspot/blogger feeds

Previous post about coding was about syndicating images in PicasaWeb with JonDesign`s Javascript gallery which uses mootools. Next task was mixing blogspot/blogger feeds in standalone web page. And again using easyXML in PHP5 it is easy as pie. In this script the interesting part is learning what the "child" is. If there is one big main structure, where similar smaller structures are built in, then these structures are like children to this main one. And in blogspot/blogger feeds there are possible to get tags or categories for each post. Additionaly, the term of the category is as attribute name inside the feed`s tag. It`s necessary to use attributes()->term, where term is attribute which has different possible names. And as these attributes could be more than one in each post or entry, then there it is where child is born. A new, child simpleXML object is created within this entry, and, correctly parsing, it is possible to get multiple items in each post. "foreach" entry categories loop inside of "foreach" entries loop.
And here is code to see it how it looks like and another DEMO link how it works.

Thus it is possible to get new blogspot/blogger feeds which are based on given tag/category, when building the hyperlink just add "/-/$category_name" in the end of blogger/blogspot full feeds link.

by the way the full blogger/blogspot feeds link is
"http://blogspotuser.blogspot.com/feeds/posts/default"
And modified link should look like

http://blogspotuser.blogspot.com/feeds/posts/default/-/category

Publication

In SPIE proceedings, about mesopic vision, its characteristics.
Last year, along masters studies in geography, I studied Ph.D in University of Latvia, Physics, mechanics and astronomics program, about psychophysics. And only thing I`d done was I, my proffesor and another collegue, we were going to this lab in France, Clermont-Ferrand to make psychophysical related experiments in fog chamber.

2011-01-17

Javascript + mootools + picasa

At last. Not so easy task finished. Finally combining Google provided Picasa online XML RSS feeds with PHP through EasyXML options with JonDesign`s Smooth Gallery which works with mootools. And here all hard work explained in simple words.
Problem - need nice web gallery. Building myself - no thanx. Using ready product - sounds good.
Problem needs. Just one need. Compatability with image servers like flickr, picasa, photobucket, etc.
Solution is combination of Javascript based web gallery with correct feed parsing.
And personally for me it includes learning new things for me, like EasyXML in php5.
Ok, how to combine these two?
1) Download JonDesign`s with mootools here.
2)Get your rss feed and learn google api here
3)And look for source here

2011-01-14

mysql queries..

SELECT DISTINCT ns
FROM (

SELECT ns, MAX( `sloj` ) m
FROM `w2`
GROUP BY ns
)foo
WHERE m <2041
ORDER BY `foo`.`ns` ASC

and another


select id, max(vērtība) m from tabula group by id having m <= 5