<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!<br><br></div>Silvia<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;<wbr>layername&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_-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/<wbr>download/web/html/es/<wbr>scripting_devel_guide/2.3/<wbr>acceso_a_objetos.html#entidad</a><br>
    </p>
    <p>Spatial operations:
<a class="m_-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/<wbr>download/web/html/es/<wbr>scripting_devel_guide/2.3/<wbr>modulo_geom.html#operaciones-<wbr>espaciales</a></p>
    <p>Current functions:
<a class="m_-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/<wbr>download/web/html/es/<wbr>scripting_devel_guide/2.3/<wbr>acceso_a_objetos.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(<wbr>name) 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_<wbr>fpoint):<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_-7164213254184264297moz-cite-prefix">El 13/10/16 a las 15:05, Silvia
      Franceschi escribió:<br>
    </div>
    <blockquote type="cite"><div><div class="h5">
      <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_-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_-7164213254184264297mimeAttachmentHeader"></fieldset>
      <br>
      </div></div><pre>______________________________<wbr>_________________
Gvsig_internacional mailing list
<a class="m_-7164213254184264297moz-txt-link-abbreviated" href="mailto:Gvsig_internacional@listserv.gva.es" target="_blank">Gvsig_internacional@listserv.<wbr>gva.es</a>

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

<a class="m_-7164213254184264297moz-txt-link-freetext" href="https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" target="_blank">https://listserv.gva.es/cgi-<wbr>bin/mailman/listinfo/gvsig_<wbr>internacional</a>
</pre>
    </blockquote>
    <br>
  </div>

<br>______________________________<wbr>_________________<br>
Gvsig_internacional mailing list<br>
<a href="mailto:Gvsig_internacional@listserv.gva.es">Gvsig_internacional@listserv.<wbr>gva.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-<wbr>bin/mailman/listinfo/gvsig_<wbr>internacional</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <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></div></div></div>