<div dir="ltr">Hi <span style="font-size:12.8px">Óscar,</span><div><span style="font-size:12.8px">always me.. :-)<br></span><div><span style="font-size:12.8px">is there also a way to write a layer in a shapefile directly from a script or do I have to load it in gvSIG and save it from there?</span></div></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Silvia</span></div><div><span style="font-size:12.8px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 14, 2016 at 1:54 PM, Silvia Franceschi <span dir="ltr">&lt;<a href="mailto:silvia.franceschi@gmail.com" target="_blank">silvia.franceschi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank you <span style="font-size:12.8px">Óscar for your detailed explanation and your help!</span><span class="HOEnZb"><font color="#888888"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Silvia</span><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 14, 2016 at 11:59 AM, Óscar Martínez <span dir="ltr">&lt;<a href="mailto:omartinez@gvsig.com" target="_blank">omartinez@gvsig.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <p>Reading again your email maybe this also answer your question:</p>
    <p>Inside the script you can make a: print dir(layer) and it will
      show you the avalaible functions of that type of object.<br>
    </p>
    <br>
    <div class="m_5121390883911626598m_8999867643063959156moz-cite-prefix">El 14/10/16 a las 11:26, Óscar Martínez
      escribió:<br>
    </div><div><div class="m_5121390883911626598h5">
    <blockquote type="cite">
      
      <p>Hi Silvia,</p>
      <p><br>
        |    Is there a way to know which functions are implemented for
        each feature type in gvSIG scripting? <br>
      </p>
      <p>If i understand correctly your question.. Quick answer, all.
        Since 2.3, we are not working with a different library for
        scripting. We improved the way to work directly with the JAVA
        API, plus new functions (like.. createShape(schema)), methods
        (like.. getValues() over a feature to return a python dict) and
        new classes (like.. FormPanel to create scripts with graphical
        interface), all to make it easy and quick to work from
        scripting. Not sure if is a good way to say it (just to explain
        this better), but we could say right now is the java api who
        hasn&#39;t have all the funcions implemented.</p>
      <p>As you can see in the script, type(layer) and type(features)
        are java objects.</p>
      <p>Running script.<br>
        layer type:  &lt;type
        &#39;org.gvsig.fmap.mapcontext.lay<wbr>ers.vectorial.FLyrVect&#39;&gt;<br>
        layer features:  &lt;type
        &#39;<a href="http://org.gvsig.fmap.dal.feature.im">org.gvsig.fmap.dal.feature.im</a><wbr>pl.featureset.DefaultFeatureSe<wbr>t&#39;&gt;<br>
        Script terminated.</p>
      <p>So, you should be able to check the javadocs, and use all the
        functions that are in there:</p>
      <p><a class="m_5121390883911626598m_8999867643063959156moz-txt-link-freetext" href="http://downloads.gvsig.org/download/gvsig-desktop-testing/dists/2.3.0/javadocs/html/" target="_blank">http://downloads.gvsig.org/dow<wbr>nload/gvsig-desktop-testing/<wbr>dists/2.3.0/javadocs/html/</a><br>
      </p>
      <p><a class="m_5121390883911626598m_8999867643063959156moz-txt-link-freetext" href="http://downloads.gvsig.org/download/gvsig-desktop-testing/dists/2.3.0/javadocs/html/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVect.html" target="_blank">http://downloads.gvsig.org/dow<wbr>nload/gvsig-desktop-testing/<wbr>dists/2.3.0/javadocs/html/org/<wbr>gvsig/fmap/mapcontext/layers/<wbr>vectorial/FLyrVect.html</a></p>
      <p><a class="m_5121390883911626598m_8999867643063959156moz-txt-link-freetext" href="http://downloads.gvsig.org/download/gvsig-desktop-testing/dists/2.3.0/javadocs/html/org/gvsig/fmap/dal/feature/impl/featureset/DefaultFeatureSet.html" target="_blank">http://downloads.gvsig.org/dow<wbr>nload/gvsig-desktop-testing/<wbr>dists/2.3.0/javadocs/html/org/<wbr>gvsig/fmap/dal/feature/impl/<wbr>featureset/DefaultFeatureSet.<wbr>html</a></p>
      <p><br>
      </p>
      <p>Plus all from scripting (we are updating this javadoc, soon
        will be more complete):</p>
      <p><a class="m_5121390883911626598m_8999867643063959156moz-txt-link-freetext" href="http://downloads.gvsig.org/download/gvsig-desktop-testing/dists/2.3.0/docs/javadocs/html/" target="_blank">http://downloads.gvsig.org/dow<wbr>nload/gvsig-desktop-testing/<wbr>dists/2.3.0/docs/javadocs/<wbr>html/</a><br>
      </p>
      <p><br>
      </p>
      <p>Deleting features should be something similar to this (delete
        all features with a filter &quot;ID &lt; 10&quot;):</p>
      # encoding: utf-8<br>
      <br>
      from gvsig import *<br>
      <br>
      def main(*args):<br>
          &quot;&quot;&quot; Delete features inside a layer&quot;&quot;&quot;<br>
      <br>
          layer = currentLayer()<br>
          features = layer.features(&quot;ID &lt; 10&quot;) #DefaultFeatureSet<br>
          <br>
      <br>
          print &quot;layer type: &quot;, type(layer)<br>
          print &quot;layer features: &quot;, type(features)<br>
          <br>
          layer.edit()<br>
          <br>
          for i in features:<br>
              ivalues = i.getValues()<br>
              print ivalues<br>
              features.delete(i)#delete over the featureset<br>
      <br>
          layer.commit()
      <p><br>
      </p>
      Best regards,<br>
      Óscar<br>
      <br>
      <br>
      <div class="m_5121390883911626598m_8999867643063959156moz-cite-prefix">El 14/10/16 a las 10:53, Silvia
        Franceschi escribió:<br>
      </div>
      <blockquote type="cite">
        <div dir="ltr">Hi <span style="font-size:12.8px">Óscar,</span>
          <div><span style="font-size:12.8px">the scripts work fine,
              many thanks again!</span></div>
          <div><span style="font-size:12.8px">May I just ask you one
              more question?</span></div>
          <div><span style="font-size:12.8px">Is there the possibility
              to remove a feature from a list of features? like
              featureslist.remove() or something like that?</span></div>
          <div><span style="font-size:12.8px">I tried with remove and
              delete but it seems that these do not exist, any idea?</span></div>
          <div><span style="font-size:12.8px"><br>
            </span></div>
          <div><span style="font-size:12.8px">Is there a way to know
              which functions are implemented for each feature type in
              gvSIG scripting?</span></div>
          <div><span style="font-size:12.8px"><br>
            </span></div>
          <div><span style="font-size:12.8px">Thanks</span></div>
          <div><span style="font-size:12.8px"><br>
            </span></div>
          <div><span style="font-size:12.8px">Silvia</span></div>
          <div><span style="font-size:12.8px"><br>
            </span></div>
        </div>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Thu, Oct 13, 2016 at 6:25 PM,
            Silvia Franceschi <span dir="ltr">&lt;<a href="mailto:silvia.franceschi@gmail.com" target="_blank">silvia.franceschi@gmail.com</a>&gt;</span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="ltr">
                <div>
                  <div>
                    <div>
                      <div>Thank you Óscar,<br>
                      </div>
                      to tell you the truth I started to use
                      currentLayer but, since I need to work with two
                      layers I didn&#39;t know how to do and tried to load
                      data from files.<br>
                    </div>
                    <div>And in any case the final script should work
                      with a list of shapefiles in a folder, so, I will
                      for sure move to the file based data source at
                      some point.<br>
                      <br>
                    </div>
                    I was following the documentation you linked, it is
                    very useful to start to get familiar with the
                    scripting environment, thanks!<br>
                    <br>
                    I will try the scripts you sent to me and let you
                    know if I will solve my problems.<br>
                    <br>
                  </div>
                  Thank you very much for the quick answer!<span class="m_5121390883911626598m_8999867643063959156HOEnZb"><font color="#888888"><br>
                      <br>
                    </font></span></div>
                <span class="m_5121390883911626598m_8999867643063959156HOEnZb"><font color="#888888">Silvia</font></span>
                <div>
                  <div class="m_5121390883911626598m_8999867643063959156h5"><br>
                    <div>
                      <div><br>
                        <br>
                        <div class="gmail_extra"><br>
                          <div class="gmail_quote">On Thu, Oct 13, 2016
                            at 6:00 PM, Óscar Martínez <span dir="ltr">&lt;<a href="mailto:omartinez@gvsig.com" target="_blank">omartinez@gvsig.com</a>&gt;</span>
                            wrote:<br>
                            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                              <div bgcolor="#FFFFFF" text="#000000">
                                <p>Hi!</p>
                                <p>If i understood correctly, you don&#39;t
                                  need to use the getSchema function.
                                  I&#39;m going to give you my solution with
                                  two test layers, give it a try and
                                  tell us if that works for you or what
                                  exactly more do you need. If you don&#39;t
                                  understand some part of the script i
                                  can explain it better. Some help is
                                  inside the script, step by step.</p>
                                <p>I recommend to you to start learning
                                  scripting using the functions
                                  currentLayer() (current layer
                                  selection in the table of contents) or
                                  currentView().getLayer(&quot;layern<wbr>ame&quot;)
                                  instead of using loadShapeFile
                                  everytime. It&#39;s easier if you just
                                  have a loaded layer in your view and
                                  access to each one each layer with
                                  currentLayer o getLayer.<br>
                                </p>
                                <p>If someone on the list want to know
                                  more about this part of scripting,
                                  here are some links from the spanish
                                  docs (hope soon in english) related to
                                  this post:</p>
                                <p>Access to features: <a class="m_5121390883911626598m_8999867643063959156m_5057304446255973355m_-7164213254184264297moz-txt-link-freetext" href="http://downloads.gvsig.org/download/web/html/es/scripting_devel_guide/2.3/acceso_a_objetos.html#entidad" target="_blank">http://downloads.gvsig.org/dow<wbr>nload/web/html/es/scripting_de<wbr>vel_guide/2.3/acceso_a_objetos<wbr>.html#entidad</a><br>
                                </p>
                                <p>Spatial operations: <a class="m_5121390883911626598m_8999867643063959156m_5057304446255973355m_-7164213254184264297moz-txt-link-freetext" href="http://downloads.gvsig.org/download/web/html/es/scripting_devel_guide/2.3/modulo_geom.html#operaciones-espaciales" target="_blank">http://downloads.gvsig.org/dow<wbr>nload/web/html/es/scripting_de<wbr>vel_guide/2.3/modulo_geom.html<wbr>#operaciones-espaciales</a></p>
                                <p>Current functions: <a class="m_5121390883911626598m_8999867643063959156m_5057304446255973355m_-7164213254184264297moz-txt-link-freetext" href="http://downloads.gvsig.org/download/web/html/es/scripting_devel_guide/2.3/acceso_a_objetos.html" target="_blank">http://downloads.gvsig.org/dow<wbr>nload/web/html/es/scripting_de<wbr>vel_guide/2.3/acceso_a_objetos<wbr>.html</a></p>
                                <p><br>
                                </p>
                                <p>Any trouble here we are!</p>
                                <p><br>
                                </p>
                                <p>Best regards,</p>
                                <p>Óscar<br>
                                </p>
                                <p><br>
                                </p>
                                <p><br>
                                </p>
                                <p>Script (layers of this test are in
                                  EPSG:25830) (feature AREA1 is a
                                  multipolygon):</p>
                                <p># encoding: utf-8<br>
                                  <br>
                                  import gvsig<br>
                                  <br>
                                  def main(*args):<br>
                                      # You need to have one view with
                                  to layers opened on it<br>
                                      # The name of the layers will be
                                  the name that appear<br>
                                      # in the table of contents of the
                                  view<br>
                                      <br>
                                      # To access to the layers that are
                                  already loaded in gvSIG<br>
                                      # gvsig.currentView() give us
                                  access to the opened view<br>
                                      # gvsig.currentView().getLayer(n<wbr>ame)
                                  give us access a specified layer<br>
                                      points =
                                  gvsig.currentView().getLayer(&quot;<wbr>points&quot;)<br>
                                      area =
                                  gvsig.currentView().getLayer(&quot;<wbr>area&quot;)<br>
                                  <br>
                                      # Access to the features<br>
                                      features_points =
                                  points.features()<br>
                                      features_area = area.features()<br>
                                  <br>
                                      # if you want access to a
                                  selection of features, not all<br>
                                      # you will have to change
                                  `features()` with `getSelection()`<br>
                                      #features_points =
                                  points.getSelection()<br>
                                      #features_area =
                                  area.getSelection()<br>
                                  <br>
                                      for farea in features_area:<br>
                                          print &quot;\nChecking : &quot;,
                                  farea.get(&quot;localId&quot;)<br>
                                          geom_farea = farea.geometry()<br>
                                          <br>
                                          #for each area, check all
                                  points without intersection<br>
                                          for fpoint in features_points:<br>
                                              geom_fpoint =
                                  fpoint.geometry()<br>
                                              <br>
                                              if not
                                  geom_farea.intersects(geom_fpo<wbr>int):<br>
                                                  print &quot;\tArea: &quot;,
                                  farea.get(&quot;localId&quot;), &quot; intersects
                                  with :&quot;, fpoint.get(&quot;ID&quot;)<br>
                                                  # work with the
                                  feature<br>
                                  <br>
                                </p>
                                Console output:<br>
                                <br>
                                Running script testing_silvia_intersec.<br>
                                <br>
                                Checking :  AREA1<br>
                                    Area:  AREA1  intersects with : 101<br>
                                    Area:  AREA1  intersects with : 102<br>
                                    Area:  AREA1  intersects with : 103<br>
                                    Area:  AREA1  intersects with : 107<br>
                                <br>
                                Checking :  AREA2<br>
                                    Area:  AREA2  intersects with : 103<br>
                                    Area:  AREA2  intersects with : 104<br>
                                    Area:  AREA2  intersects with : 105<br>
                                    Area:  AREA2  intersects with : 106<br>
                                    Area:  AREA2  intersects with : 107<br>
                                    Area:  AREA2  intersects with : 108<br>
                                Script testing_silvia_intersec
                                terminated.<br>
                                <br>
                                <br>
                                <br>
                                <div class="m_5121390883911626598m_8999867643063959156m_5057304446255973355m_-7164213254184264297moz-cite-prefix">El
                                  13/10/16 a las 15:05, Silvia
                                  Franceschi escribió:<br>
                                </div>
                                <blockquote type="cite">
                                  <div>
                                    <div class="m_5121390883911626598m_8999867643063959156m_5057304446255973355h5">
                                      <div dir="ltr">Hi all,
                                        <div>I am trying to write my
                                          first script in gvSIG and
                                          Python, I need to read a point
                                          shapefile and filter some
                                          elements that are outside a
                                          defined area.</div>
                                        <div>To do this I have to read
                                          two input layers, one with the
                                          points and one with the area
                                          and then work on each single
                                          features of the point layer.</div>
                                        <div>I started with the
                                          selection of the input layers
                                          using a filechooser dialog
                                          (commonsdialog.filechooser)
                                          and then I need to obtain the
                                          schema of these layers, but it
                                          seems that the object
                                          filechooser do not have the
                                          .getSchema() function.</div>
                                        <div>Do you have any idea on how
                                          to obtain the schema from a
                                          vector layer selected using
                                          the filechooser?</div>
                                        <div><br>
                                        </div>
                                        <div>Thanks in advance for any
                                          help!</div>
                                        <div><br>
                                        </div>
                                        <div>Silvia</div>
                                        <div> <br clear="all">
                                          <div><br>
                                          </div>
                                          -- <br>
                                          <div class="m_5121390883911626598m_8999867643063959156m_5057304446255973355m_-7164213254184264297gmail_signature">
                                            <div dir="ltr">
                                              <div>
                                                <div dir="ltr">
                                                  <div>
                                                    <div dir="ltr">
                                                      <div style="font-size:small">ing.
                                                        Silvia
                                                        Franceschi<br>
                                                        Via Latemar, 22</div>
                                                      <div style="font-size:small">38030
                                                        Castello di
                                                        Fiemme (TN)<br>
                                                        <br>
                                                        tel: <a href="tel:0039%20-3384501332" value="+393384501332" target="_blank">0039
                                                          -3384501332</a></div>
                                                    </div>
                                                  </div>
                                                </div>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                      <br>
                                      <fieldset class="m_5121390883911626598m_8999867643063959156m_5057304446255973355m_-7164213254184264297mimeAttachmentHeader"></fieldset>
                                      <br>
                                    </div>
                                  </div>
                                  <pre>______________________________<wbr>_________________
Gvsig_internacional mailing list
<a class="m_5121390883911626598m_8999867643063959156m_5057304446255973355m_-7164213254184264297moz-txt-link-abbreviated" href="mailto:Gvsig_internacional@listserv.gva.es" target="_blank">Gvsig_internacional@listserv.g<wbr>va.es</a>

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

<a class="m_5121390883911626598m_8999867643063959156m_5057304446255973355m_-7164213254184264297moz-txt-link-freetext" href="https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" target="_blank">https://listserv.gva.es/cgi-bi<wbr>n/mailman/listinfo/gvsig_inter<wbr>nacional</a>
</pre>
    </blockquote>
    

  </div>


______________________________<wbr>_________________

Gvsig_internacional mailing list

<a href="mailto:Gvsig_internacional@listserv.gva.es" target="_blank">Gvsig_internacional@listserv.g<wbr>va.es</a>



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



<a href="https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" rel="noreferrer" target="_blank">https://listserv.gva.es/cgi-bi<wbr>n/mailman/listinfo/gvsig_inter<wbr>nacional</a>


</blockquote></div>


-- 
<div class="m_5121390883911626598m_8999867643063959156m_5057304446255973355gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="font-size:small">ing. Silvia Franceschi
Via Latemar, 22</div><div style="font-size:small">38030 Castello di Fiemme (TN)

tel: <a href="tel:0039%20-3384501332" value="+393384501332" target="_blank">0039 -3384501332</a></div></div></div></div></div></div></div>
</div></div></div></div></div></div>
</blockquote></div>

<div>
</div>-- 
<div class="m_5121390883911626598m_8999867643063959156gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="font-size:small">ing. Silvia Franceschi
Via Latemar, 22</div><div style="font-size:small">38030 Castello di Fiemme (TN)

tel: <a href="tel:0039%20-3384501332" value="+393384501332" target="_blank">0039 -3384501332</a></div></div></div></div></div></div></div>
</div>


<fieldset class="m_5121390883911626598m_8999867643063959156mimeAttachmentHeader"></fieldset>
<pre>______________________________<wbr>_________________
Gvsig_internacional mailing list
<a class="m_5121390883911626598m_8999867643063959156moz-txt-link-abbreviated" href="mailto:Gvsig_internacional@listserv.gva.es" target="_blank">Gvsig_internacional@listserv.g<wbr>va.es</a>

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

<a class="m_5121390883911626598m_8999867643063959156moz-txt-link-freetext" href="https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" target="_blank">https://listserv.gva.es/cgi-bi<wbr>n/mailman/listinfo/gvsig_inter<wbr>nacional</a>
</pre>

</blockquote>


<fieldset class="m_5121390883911626598m_8999867643063959156mimeAttachmentHeader"></fieldset>
<pre>______________________________<wbr>_________________
Gvsig_internacional mailing list
<a class="m_5121390883911626598m_8999867643063959156moz-txt-link-abbreviated" href="mailto:Gvsig_internacional@listserv.gva.es" target="_blank">Gvsig_internacional@listserv.g<wbr>va.es</a>

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

<a class="m_5121390883911626598m_8999867643063959156moz-txt-link-freetext" href="https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" target="_blank">https://listserv.gva.es/cgi-bi<wbr>n/mailman/listinfo/gvsig_inter<wbr>nacional</a>
</pre>

</blockquote>
</div></div></div><br>______________________________<wbr>_________________<br>
Gvsig_internacional mailing list<br>
<a href="mailto:Gvsig_internacional@listserv.gva.es" target="_blank">Gvsig_internacional@listserv.g<wbr>va.es</a><br>
<br>
To see the archives, edit your preferences or unsubscribe from this mailing list, please access this url:<br>
<br>
<a href="https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" rel="noreferrer" target="_blank">https://listserv.gva.es/cgi-bi<wbr>n/mailman/listinfo/gvsig_inter<wbr>nacional</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_5121390883911626598gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="font-size:small">ing. Silvia Franceschi<br>Via Latemar, 22</div><div style="font-size:small">38030 Castello di Fiemme (TN)<br><br>tel: <a href="tel:0039%20-3384501332" value="+393384501332" target="_blank">0039 -3384501332</a></div></div></div></div></div></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="font-size:small">ing. Silvia Franceschi<br>Via Latemar, 22</div><div style="font-size:small">38030 Castello di Fiemme (TN)<br><br>tel: 0039 -3384501332</div></div></div></div></div></div></div>
</div>