Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2013-09-27 Thread phil_murcia
Antonio,

Thanks very much for all the help! I have it working using a Jython
function. I think now I will further research the scripting capabilities of
2.0 - is it worth investing some time in this?

thanks,

Phil



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp4103134p5080520.html
Sent from the gvSIG users mailing list archive at Nabble.com.
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2013-09-27 Thread Antonio Falciano
Il 27/09/2013 10:23, Antonio Falciano ha scritto:
> Il 27/09/2013 10:18, Antonio Falciano ha scritto:
>> Il 27/09/2013 09:43, phil_murcia ha scritto:
>>> Hi Antonio,
>>>
>>> Thanks so much for the advice. It seems once you get to grips with the
>>> Jython functions you gain a lot of capabilities. However I cannot get my
>>> expression to work, without wanting to turn this extremely useful thread
>>> into a troubleshooting discussion, I cannot work out why.
>>>
>>> I have created my .py file, and switched in all the correct headings
>>> (I have
>>> also checked for line errors in spyder environment). In gvSIG I begin
>>> editing the layer, open the attribute table, select the 'compat'
>>> column and
>>> then open the expression calculator. I then go to the advance tab and
>>> explore for the correct .py file, on loading this I am still unable to
>>> click
>>> 'ok' and the 'evaluate' seemingly still does nothing. With the .py
>>> loaded I
>>> then tried switching back to the general tab and entering the second
>>> expression "compat([Agr],[Urb],[For],[Com],[Pub])" - but when I then
>>> try and
>>> click ok I then get an error expression with a traceback description.
>>>
>>> I am not implementing the expression correctly or am I missing something
>>> obvious?
>>
>> Hi Phil,
>> sorry, I haven't tested the script yesterday. You can try with the
>> script in attachment in order to respect the right indentation. I have
>> also substituted the "for" reserved word with "fore". Hope this helps!
>
> Ops... It seems that an elif was not well indented. Please correct it!

Ops again... The right expression to type is:
compat([Agr],[Urb],[For],[Com],[Pub],[Land-use B])
[Land-use B] was missing.

Antonio

-- 
Antonio Falciano
http://www.linkedin.com/in/antoniofalciano
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2013-09-27 Thread Antonio Falciano
Il 27/09/2013 10:18, Antonio Falciano ha scritto:
> Il 27/09/2013 09:43, phil_murcia ha scritto:
>> Hi Antonio,
>>
>> Thanks so much for the advice. It seems once you get to grips with the
>> Jython functions you gain a lot of capabilities. However I cannot get my
>> expression to work, without wanting to turn this extremely useful thread
>> into a troubleshooting discussion, I cannot work out why.
>>
>> I have created my .py file, and switched in all the correct headings
>> (I have
>> also checked for line errors in spyder environment). In gvSIG I begin
>> editing the layer, open the attribute table, select the 'compat'
>> column and
>> then open the expression calculator. I then go to the advance tab and
>> explore for the correct .py file, on loading this I am still unable to
>> click
>> 'ok' and the 'evaluate' seemingly still does nothing. With the .py
>> loaded I
>> then tried switching back to the general tab and entering the second
>> expression "compat([Agr],[Urb],[For],[Com],[Pub])" - but when I then
>> try and
>> click ok I then get an error expression with a traceback description.
>>
>> I am not implementing the expression correctly or am I missing something
>> obvious?
>
> Hi Phil,
> sorry, I haven't tested the script yesterday. You can try with the
> script in attachment in order to respect the right indentation. I have
> also substituted the "for" reserved word with "fore". Hope this helps!

Ops... It seems that an elif was not well indented. Please correct it!

Cheers,
Antonio

-- 
Antonio Falciano
http://www.linkedin.com/in/antoniofalciano
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2013-09-27 Thread Antonio Falciano

Il 27/09/2013 09:43, phil_murcia ha scritto:

Hi Antonio,

Thanks so much for the advice. It seems once you get to grips with the
Jython functions you gain a lot of capabilities. However I cannot get my
expression to work, without wanting to turn this extremely useful thread
into a troubleshooting discussion, I cannot work out why.

I have created my .py file, and switched in all the correct headings (I have
also checked for line errors in spyder environment). In gvSIG I begin
editing the layer, open the attribute table, select the 'compat' column and
then open the expression calculator. I then go to the advance tab and
explore for the correct .py file, on loading this I am still unable to click
'ok' and the 'evaluate' seemingly still does nothing. With the .py loaded I
then tried switching back to the general tab and entering the second
expression "compat([Agr],[Urb],[For],[Com],[Pub])" - but when I then try and
click ok I then get an error expression with a traceback description.

I am not implementing the expression correctly or am I missing something
obvious?


Hi Phil,
sorry, I haven't tested the script yesterday. You can try with the
script in attachment in order to respect the right indentation. I have
also substituted the "for" reserved word with "fore". Hope this helps!

Cheers,
Antonio

--
Antonio Falciano
http://www.linkedin.com/in/antoniofalciano
def compat(agr,urb,fore,com,pub,lub):
  if lub=="Agr":
result=agr
  elif lub=="Urb":
result=urb
  elif lub=="For":
result=fore
   elif lub=="Com":
result=com
  elif lub=="Pub":
result=pub
  else:
result=-1
  return result ___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2013-09-27 Thread phil_murcia
Hi Antonio,

Thanks so much for the advice. It seems once you get to grips with the
Jython functions you gain a lot of capabilities. However I cannot get my
expression to work, without wanting to turn this extremely useful thread
into a troubleshooting discussion, I cannot work out why.

I have created my .py file, and switched in all the correct headings (I have
also checked for line errors in spyder environment). In gvSIG I begin
editing the layer, open the attribute table, select the 'compat' column and
then open the expression calculator. I then go to the advance tab and
explore for the correct .py file, on loading this I am still unable to click
'ok' and the 'evaluate' seemingly still does nothing. With the .py loaded I
then tried switching back to the general tab and entering the second
expression "compat([Agr],[Urb],[For],[Com],[Pub])" - but when I then try and
click ok I then get an error expression with a traceback description.

I am not implementing the expression correctly or am I missing something
obvious? 

Thanks,

Phil



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp4103134p5080431.html
Sent from the gvSIG users mailing list archive at Nabble.com.
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2013-09-26 Thread Antonio Falciano
Il 26/09/2013 14:10, phil_murcia ha scritto:
> I am trying to create a python expression to insert into the expression
> calculator that fills a column for me in the attribute table, but am
> struggling to find the correct syntax - or even successfully implement the
> simplest of python expressions. The table shows the compatibility of
> Land-use A with each instance of land use B, but I need to create a final
> column that can select the correct number from the correct column, depending
> on what is in the Land-use B column. An example of my attribute table is
> shown below.
>
> **Compatibility:**
>
>  ID  |  Land-use A |  Agr  |  Urb  | For  | Com |  Pub | Land-use B |
> Compat
>   1   N  14  3 0   2
> Agr
>   2   G  23  5 1   0
> Pub
>   3   K  42  3 5   1
> Urb
>   4   N  14  3 0   2
> Urb
>
> An example of my desired attribute table can be seen below:
>
> **Desired:**
>
>  ID  |  Land-use A |  Agr  |  Urb  | For  | Com |  Pub | Land-use B |
> Compat
>   1   N 143   02
> Agr  1
>   2   G 235   10
> Pub  0
>   3   K 423   51
> Urb  2
>   4   N 143   02
> Urb  4
>
> Perhaps it is possible to do this in the gvSIG expression calculator without
> import a .py file - but either way I can not seem to get the syntax right.
> Any help would be much appreciated.

Hi Phil,
you should define a Jython function in order to accomplish this task.
For instance:

def compat(agr,urb,for,com,pub,lub):
   if lub=="Agr":
 result=agr
   elif lub=="Urb":
 result=urb
   elif lub=="For":
 result=for
   elif lub=="Com":
 result=com
   elif lub=="Pub":
 result=pub
   else:
 result=-1
   return result

Save it in a file and process it as advanced expression in the field
calculator. Then select the header of Compat column and type the
following expression:

compat([Agr],[Urb],[For],[Com],[Pub])

It should work as you expect.

Cheers,
Antonio

-- 
Antonio Falciano
http://www.linkedin.com/in/antoniofalciano
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2013-09-26 Thread phil_murcia
I am trying to create a python expression to insert into the expression
calculator that fills a column for me in the attribute table, but am
struggling to find the correct syntax - or even successfully implement the
simplest of python expressions. The table shows the compatibility of
Land-use A with each instance of land use B, but I need to create a final
column that can select the correct number from the correct column, depending
on what is in the Land-use B column. An example of my attribute table is
shown below.

**Compatibility:**

ID  |  Land-use A |  Agr  |  Urb  | For  | Com |  Pub | Land-use B |
Compat
 1   N  14  3 0   2
Agr   
 2   G  23  5 1   0
Pub
 3   K  42  3 5   1
Urb
 4   N  14  3 0   2
Urb

An example of my desired attribute table can be seen below:

**Desired:**

ID  |  Land-use A |  Agr  |  Urb  | For  | Com |  Pub | Land-use B |
Compat
 1   N 143   02   
Agr  1 
 2   G 235   10   
Pub  0
 3   K 423   51   
Urb  2
 4   N 143   02   
Urb  4

Perhaps it is possible to do this in the gvSIG expression calculator without
import a .py file - but either way I can not seem to get the syntax right.
Any help would be much appreciated.




--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp4103134p5080184.html
Sent from the gvSIG users mailing list archive at Nabble.com.
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2011-12-15 Thread Antonio Falciano
Il 15/12/2011 10.34, Nacho Uve ha scritto:
> Thanks for sharing this issue on the list! I think scripting is a very
> powerful tool for many GIS users.
>
> I miss very much documentation, manual, tutorials and/or examples for
> this topic. Time ago, I tried to use it, but I gave up shortly
> thereafter because my lack of knowledge about it.
>
> Maybe a short post in the blog can be very very useful to start
> working... :-)

Hi Nacho,
here's a short but useful blog post in order to start working with
Jython scripting in gvSIG [1]. There's also the Scripting tutorial on
Joinup [2] and furthermore there are some useful snippets of Jython code
in gvSIG mailing lists archives [3]. Finally, an interesting discussion
about the gvSIG 2.0 scripting capabilities [4] and two working examples [5].
So... Happy Jython coding! ;)

Cheers,
Antonio

[1] 
http://dominoc925.blogspot.com/2011/07/simple-gvsig-jython-console-script-to.html
[2] 
https://joinup.ec.europa.eu/sites/default/files/gvsig-1_0-scripting-tutorial-v2-en.zip
[3] 
http://osgeo-org.1803224.n2.nabble.com/template/NamlServlet.jtp?macro=search_page&node=251&query=jython
[4] 
http://osgeo-org.1803224.n2.nabble.com/gvsig-1-9-x-2-0-and-jython-td4836869.html
[5] 
http://osgeo-org.1803224.n2.nabble.com/Add-transparency-to-all-the-symbols-of-a-legend-1-td7093161.html

-- 
Antonio Falciano
http://www.linkedin.com/in/antoniofalciano
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2011-12-15 Thread Nacho Uve
2011/12/14 Antonio Falciano 

> Great, Iacopo! I had not thought this kind of solution.
> I'm happy to know that someone likes to use Jython with gvSIG!
> A public script repository is missing yet. I hope that it will be very
> soon thanks to the new scripting capabilities of gvSIG 2.0.
>

Thanks for sharing this issue on the list! I think scripting is a very
powerful tool for many GIS users.

I miss very much documentation, manual, tutorials and/or examples for this
topic. Time ago, I tried to use it, but I gave up shortly thereafter
because my lack of knowledge about it.

Maybe a short post in the blog can be very very useful to start working...
:-)

Volunteers?

Regards,



>
> Cheers,
> Antonio
>
> Il 14/12/2011 11.50, iaborsi ha scritto:
> > SOLVED!
> > It is enough to save the new Module(s) within the following gvSIG path:
> >
> > /bin/gvSIG/extensiones/org.gvsig.scripting/scripts/jython/Lib
> >
> > Of course, the Module has to be Jython compliant.
> >
> > Regards,
> > Iacopo
> >
> >
> > Iacopo Borsi
> > Dipartimento di Matematica U.Dini
> > Università di Firenze.
> > V.le Morgagni 67/A
> > 50134 Firenze - Italy
> > Tel. +39.0554237147
> > Fax. +39.0554237133
> > e-mail [hidden email] 
> > Web: http://web.math.unifi.it/users/borsi
> > http://sidgrid.isti.cnr.it
> >
> > Quoting "Antonio Falciano [via OSGeo.org]"
> > <[hidden email] >:
> >
> >  >
> >  >
> >  > Il 13/12/2011 10.28, iaborsi ha scritto:
> >  >> Hi Antonio,
> >  >> thanks a lot! I've tried that: very easy, and it works perfectly!
> >  >> I take this opportunity to make an additional question: if in writing
> >  >> this Jython function I need additional Modules (typically an original
> >  >> group of functions defined by myself) which is the right path to save
> >  >> this stuff? I guess is the same directory from which I upload my
> Jython
> >  >> function, isn't it?
> >  >> To be clearer (following you example below): I want to modify your
> >  >> example script "conversion.py" in this way:
> >  >> ---
> >  >> from MyNewModule import *
> >  >>
> >  >> def m2tokm2(value):
> >  >> temp=value/100
> >  >> result = MyNewFunction(temp)
> >  >> return result
> >  >> ---
> >  >> where MyNewFunction() is defined within the module MyNewModule.
> >  >>
> >  >> I guess I have to save the module within the same path of
> > conversion.py.
> >  >> Right?
> >  >
> >  > Good idea, Iacopo! Importing further modules would extend the
> >  > potentiality of advanced expressions. It should be possible to import
> a
> >  > module within the same path, however it returns always a Jython
> >  > exception. Probably the simplest way to use other functions contained
> in
> >  > other module(s) consists in processing them before, even if it's not
> >  > pythonic at all.
> >  >
> >  > Cheers,
> >  > Antonio
> >  >
> >  > --
> >  > Antonio Falciano
> >  > http://www.linkedin.com/in/antoniofalciano
> >  > ___
> >  > Gvsig_internacional mailing list
> >  > [hidden email] 
> >  >
> >  > To see the archives, edit your preferences or unsubscribe from this
> >  > mailing list, please access this url:
> >  >
> >  > http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
> >  >
> >  >
> >  > ___
> >  > If you reply to this email, your message will be added to the
> >  > discussion below:
> >  >
> >
> http://osgeo-org.1803224.n2.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp7086102p7092993.html
> >  > To start a new topic under gvSIG users, email
> >  > [hidden email] 
> >  > To unsubscribe from gvSIG users, visit
> >  >
> >
> >
> > 
> > This message was sent using IMP, the Internet Messaging Program.
> >
> >
> >
> > 
> > View this message in context: Re: Field Calculator: look for an
> > expression saved in a file
> > <
> http://osgeo-org.1803224.n2.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp7086102p7093061.html
> >
> > Sent from the gvSIG users mailing list archive
> >  at
> > Nabble.com.
> >
> >
> > ___
> > Gvsig_internacional mailing list
> > Gvsig_internacional@listserv.gva.es
> >
> > To see the archives, edit your preferences or unsubscribe from this
> mailing list, please access this url:
> >
> > http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>
> --
> Antonio Falciano
> http://www.linkedin.com/in/antoniofalciano
> ___
> Gvsig_internacional mailing list
> Gvsig_internacional@listserv.gva.es
>
> To see the archives, edit your preferences or unsubscribe from this
> mailing list, please access this url:
>
> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>



-- 
Juan Ignacio Varela García
_

Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2011-12-14 Thread Jose Manuel Vivó Arnal ( Chema )
El 14/12/11 11:32, Antonio Falciano escribió:
> Il 13/12/2011 10.28, iaborsi ha scritto:
>> Hi Antonio,
>> thanks a lot! I've tried that: very easy, and it works perfectly!
>> I take this opportunity to make an additional question: if in writing
>> this Jython function I need additional Modules (typically an original
>> group of functions defined by myself) which is the right path to save
>> this stuff? I guess is the same directory from which I upload my Jython
>> function, isn't it?
>> To be clearer (following you example below): I want to modify your
>> example script "conversion.py" in this way:
>> ---
>> from MyNewModule import *
>>
>> def m2tokm2(value):
>> temp=value/100
>> result = MyNewFunction(temp)
>> return result
>> ---
>> where MyNewFunction() is defined within the module MyNewModule.
>>
>> I guess I have to save the module within the same path of conversion.py.
>> Right?
>
> Good idea, Iacopo! Importing further modules would extend the
> potentiality of advanced expressions. It should be possible to import a
> module within the same path, however it returns always a Jython
> exception. Probably the simplest way to use other functions contained in
> other module(s) consists in processing them before, even if it's not
> pythonic at all.
>
> Cheers,
> Antonio
>
I can remember that a file "__init__.py" is needed to import any module 
form a folder [1]. So create a empty file in this folder and try again.

I think it worth a try, doesn't it? ;)

[1] 
http://docs.python.org/release/2.1.2/tut/node8.html#SECTION00840

Regards,
Chema.
-- 
Jose Manuel Vivó Arnal
DiSiD Technologies S.L. (http://www.disid.com)
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2011-12-14 Thread Antonio Falciano
Great, Iacopo! I had not thought this kind of solution.
I'm happy to know that someone likes to use Jython with gvSIG!
A public script repository is missing yet. I hope that it will be very
soon thanks to the new scripting capabilities of gvSIG 2.0.

Cheers,
Antonio

Il 14/12/2011 11.50, iaborsi ha scritto:
> SOLVED!
> It is enough to save the new Module(s) within the following gvSIG path:
>
> /bin/gvSIG/extensiones/org.gvsig.scripting/scripts/jython/Lib
>
> Of course, the Module has to be Jython compliant.
>
> Regards,
> Iacopo
>
>
> Iacopo Borsi
> Dipartimento di Matematica U.Dini
> Università di Firenze.
> V.le Morgagni 67/A
> 50134 Firenze - Italy
> Tel. +39.0554237147
> Fax. +39.0554237133
> e-mail [hidden email] 
> Web: http://web.math.unifi.it/users/borsi
> http://sidgrid.isti.cnr.it
>
> Quoting "Antonio Falciano [via OSGeo.org]"
> <[hidden email] >:
>
>  >
>  >
>  > Il 13/12/2011 10.28, iaborsi ha scritto:
>  >> Hi Antonio,
>  >> thanks a lot! I've tried that: very easy, and it works perfectly!
>  >> I take this opportunity to make an additional question: if in writing
>  >> this Jython function I need additional Modules (typically an original
>  >> group of functions defined by myself) which is the right path to save
>  >> this stuff? I guess is the same directory from which I upload my Jython
>  >> function, isn't it?
>  >> To be clearer (following you example below): I want to modify your
>  >> example script "conversion.py" in this way:
>  >> ---
>  >> from MyNewModule import *
>  >>
>  >> def m2tokm2(value):
>  >> temp=value/100
>  >> result = MyNewFunction(temp)
>  >> return result
>  >> ---
>  >> where MyNewFunction() is defined within the module MyNewModule.
>  >>
>  >> I guess I have to save the module within the same path of
> conversion.py.
>  >> Right?
>  >
>  > Good idea, Iacopo! Importing further modules would extend the
>  > potentiality of advanced expressions. It should be possible to import a
>  > module within the same path, however it returns always a Jython
>  > exception. Probably the simplest way to use other functions contained in
>  > other module(s) consists in processing them before, even if it's not
>  > pythonic at all.
>  >
>  > Cheers,
>  > Antonio
>  >
>  > --
>  > Antonio Falciano
>  > http://www.linkedin.com/in/antoniofalciano
>  > ___
>  > Gvsig_internacional mailing list
>  > [hidden email] 
>  >
>  > To see the archives, edit your preferences or unsubscribe from this
>  > mailing list, please access this url:
>  >
>  > http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>  >
>  >
>  > ___
>  > If you reply to this email, your message will be added to the
>  > discussion below:
>  >
> http://osgeo-org.1803224.n2.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp7086102p7092993.html
>  > To start a new topic under gvSIG users, email
>  > [hidden email] 
>  > To unsubscribe from gvSIG users, visit
>  >
>
>
> 
> This message was sent using IMP, the Internet Messaging Program.
>
>
>
> 
> View this message in context: Re: Field Calculator: look for an
> expression saved in a file
> 
> Sent from the gvSIG users mailing list archive
>  at
> Nabble.com.
>
>
> ___
> Gvsig_internacional mailing list
> Gvsig_internacional@listserv.gva.es
>
> To see the archives, edit your preferences or unsubscribe from this mailing 
> list, please access this url:
>
> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional

-- 
Antonio Falciano
http://www.linkedin.com/in/antoniofalciano
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2011-12-14 Thread iaborsi
SOLVED!
It is enough to save the new Module(s) within the following gvSIG path:

/bin/gvSIG/extensiones/org.gvsig.scripting/scripts/jython/Lib

Of course, the Module has to be Jython compliant.

Regards,
Iacopo


Iacopo Borsi
Dipartimento di Matematica U.Dini
Università di Firenze.
V.le Morgagni 67/A
50134 Firenze - Italy
Tel. +39.0554237147
Fax. +39.0554237133
e-mail bo...@math.unifi.it
Web:   http://web.math.unifi.it/users/borsi
http://sidgrid.isti.cnr.it

Quoting "Antonio Falciano [via OSGeo.org]"  
:

>
>
> Il 13/12/2011 10.28, iaborsi ha scritto:
>> Hi Antonio,
>> thanks a lot! I've tried that: very easy, and it works perfectly!
>> I take this opportunity to make an additional question: if in writing
>> this Jython function I need additional Modules (typically an original
>> group of functions defined by myself) which is the right path to save
>> this stuff? I guess is the same directory from which I upload my Jython
>> function, isn't it?
>> To be clearer (following you example below): I want to modify your
>> example script "conversion.py" in this way:
>> ---
>> from MyNewModule import *
>>
>> def m2tokm2(value):
>> temp=value/100
>> result = MyNewFunction(temp)
>> return result
>> ---
>> where MyNewFunction() is defined within the module MyNewModule.
>>
>> I guess I have to save the module within the same path of conversion.py.
>> Right?
>
> Good idea, Iacopo! Importing further modules would extend the
> potentiality of advanced expressions. It should be possible to import a
> module within the same path, however it returns always a Jython
> exception. Probably the simplest way to use other functions contained in
> other module(s) consists in processing them before, even if it's not
> pythonic at all.
>
> Cheers,
> Antonio
>
> --
> Antonio Falciano
> http://www.linkedin.com/in/antoniofalciano
> ___
> Gvsig_internacional mailing list
> Gvsig_internacional@listserv.gva.es
>
> To see the archives, edit your preferences or unsubscribe from this   
> mailing list, please access this url:
>
> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>
>
> ___
> If you reply to this email, your message will be added to the   
> discussion below:
> http://osgeo-org.1803224.n2.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp7086102p7092993.html
> To start a new topic under gvSIG users, email   
> ml-node+s1803224n2009903...@n2.nabble.com
> To unsubscribe from gvSIG users, visit   
> http://osgeo-org.1803224.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2009903&code=Ym9yc2lAbWF0aC51bmlmaS5pdHwyMDA5OTAzfC01MjEyNTE4ODM=



-- 



This message was sent using IMP, the Internet Messaging Program.




--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp7086102p7093061.html
Sent from the gvSIG users mailing list archive at Nabble.com.___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2011-12-14 Thread Antonio Falciano
Il 13/12/2011 10.28, iaborsi ha scritto:
> Hi Antonio,
> thanks a lot! I've tried that: very easy, and it works perfectly!
> I take this opportunity to make an additional question: if in writing
> this Jython function I need additional Modules (typically an original
> group of functions defined by myself) which is the right path to save
> this stuff? I guess is the same directory from which I upload my Jython
> function, isn't it?
> To be clearer (following you example below): I want to modify your
> example script "conversion.py" in this way:
> ---
> from MyNewModule import *
>
> def m2tokm2(value):
> temp=value/100
> result = MyNewFunction(temp)
> return result
> ---
> where MyNewFunction() is defined within the module MyNewModule.
>
> I guess I have to save the module within the same path of conversion.py.
> Right?

Good idea, Iacopo! Importing further modules would extend the
potentiality of advanced expressions. It should be possible to import a
module within the same path, however it returns always a Jython
exception. Probably the simplest way to use other functions contained in
other module(s) consists in processing them before, even if it's not
pythonic at all.

Cheers,
Antonio

-- 
Antonio Falciano
http://www.linkedin.com/in/antoniofalciano
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2011-12-13 Thread iaborsi
Hi Antonio,
thanks a lot! I've tried that: very easy, and it works perfectly!
I take this opportunity to make an additional question: if in writing 
this Jython function I need additional Modules  (typically an original 
group of functions defined by myself) which is the right path to save 
this stuff? I guess is the same directory from which I upload my Jython 
function, isn't it?
To be clearer (following you example below): I want to modify your 
example script "conversion.py" in this way:
---
from MyNewModule import *

def m2tokm2(value):
   temp=value/100
   result = MyNewFunction(temp)
   return result
--- 
where MyNewFunction() is defined within the module MyNewModule.

I guess I have to save the module within the same path of conversion.py. 
Right?

Thanks again and best regards,
I.

-- 
Iacopo Borsi
Dipartimento di Matematica U.Dini
Università di Firenze.
V.le Morgagni 67/A
50134 Firenze - Italy
Tel. +39.0554237147
Fax. +39.0554237133
e-mail bo...@math.unifi.it
Web:   http://web.math.unifi.it/users/borsi
http://sidgrid.isti.cnr.it



 
Antonio Falciano [via OSGeo.org] wrote:
> Il 12/12/2011 14.39, iaborsi ha scritto:
>
> > Hi,
> > I'm quite new with gvSIG.
> > This is my question.
> > I wish to write a specific "expression" as Python script, to be used
> > in the Field Calculator (after starting an editing session).
> > Reading through the Manual, I see that it is possible just saving this
> > script in a Python file and uploading it from the appropriate box:
> > Field Calculator > Advanced tab.
> > I've done it, also using some dummy script, but it doesn't work.
> > Can anybody post some explicit example of using this feature?
>
> Iacopo,
> you have simply to define a Jython function which returns the result of
> your calculation, load it from the Advanced tab and finally use that
> function as the built-in functions of the Field Calculator.
> For instance, if we have a field containing the area expressed in square
> meters (e.g. SUP_M2) and we want to convert it in square kilometers,
> we can write:
>
> def m2tokm2(value):
>result=value/100
>return result
>
> We save this script as conversion.py, load it from the Advanced tab
> and then we can use the Jython function writing in correspondence of
> a new field called e.g. SUP_KM2:
>
> m2tokm2([SUP_M2])
>
> Finally, the field SUP_KM2 will be populated by area expressed in km^2.
>
> ciao
> Antonio
>
> -- 
> Antonio Falciano
> http://www.linkedin.com/in/antoniofalciano
> ___
> Gvsig_internacional mailing list
> [hidden email] 
>
> To see the archives, edit your preferences or unsubscribe from this 
> mailing list, please access this url:
>
> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>
>
> 
> If you reply to this email, your message will be added to the 
> discussion below:
> http://osgeo-org.1803224.n2.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp7086102p7089143.html
>  
>
> To start a new topic under gvSIG users, email 
> ml-node+s1803224n2009903...@n2.nabble.com
> To unsubscribe from gvSIG users, click here 
> .
> NAML 
> 
>  
>




--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Field-Calculator-look-for-an-expression-saved-in-a-file-tp7086102p7089278.html
Sent from the gvSIG users mailing list archive at Nabble.com.___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


Re: [Gvsig_english] Field Calculator: look for an expression saved in a file

2011-12-13 Thread Antonio Falciano
Il 12/12/2011 14.39, iaborsi ha scritto:
> Hi,
> I'm quite new with gvSIG.
> This is my question.
> I wish to write a specific "expression" as Python script, to be used
> in the Field Calculator (after starting an editing session).
> Reading through the Manual, I see that it is possible just saving this
> script in a Python file and uploading it from the appropriate box:
> Field Calculator > Advanced tab.
> I've done it, also using some dummy script, but it doesn't work.
> Can anybody post some explicit example of using this feature?

Iacopo,
you have simply to define a Jython function which returns the result of
your calculation, load it from the Advanced tab and finally use that
function as the built-in functions of the Field Calculator.
For instance, if we have a field containing the area expressed in square
meters (e.g. SUP_M2) and we want to convert it in square kilometers,
we can write:

def m2tokm2(value):
   result=value/100
   return result

We save this script as conversion.py, load it from the Advanced tab
and then we can use the Jython function writing in correspondence of
a new field called e.g. SUP_KM2:

m2tokm2([SUP_M2])

Finally, the field SUP_KM2 will be populated by area expressed in km^2.

ciao
Antonio

-- 
Antonio Falciano
http://www.linkedin.com/in/antoniofalciano
___
Gvsig_internacional mailing list
Gvsig_internacional@listserv.gva.es

To see the archives, edit your preferences or unsubscribe from this mailing 
list, please access this url:

http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional