<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hi Silvia,</p>
    <p>Sorry with our last emails I forgot this one.</p>
    <p>So this two quick scripts:</p>
    <p>- a 2D point layer with a column of z of which I would create a
      3D point layer</p>
    <pre># encoding: utf-8

import gvsig
from gvsig import geom

def main(*args):

    layer = gvsig.currentLayer()
    features = layer.features()

    #Create schema based on a existing schema
    sch = gvsig.createFeatureType(layer.getSchema())
    #We modified the geometry field of that schema for the geometry type that we want
    sch.getDefaultGeometryAttribute().setGeometryType(geom.POINT, geom.D3)

    #new shape
    shp = gvsig.createShape(sch, prefixname="points3d")
    
    for feature in features:

        g = feature.geometry()
        #print g.getX(), g.getY(), feature.get("z")
        
        z = float(feature.get("z")) # z field convert to a float number (in my case was a string field)
        point3d = geom.createPoint(geom.D3, g.getX(), g.getY(), z)

        values = feature.getValues()
        values["GEOMETRY"] = point3d
        
        shp.append(values)

    shp.commit()
    gvsig.currentView().addLayer(shp)
</pre>
    - a 2D line layer with a column containing the elevation of each
    corner of the line which I would create a 3D line layer.<br>
    (<b>This script will be useful for lines and for polygons</b>,
    becouse their geometry works in the same way)<br>
    <br>
    <pre># encoding: utf-8</pre>
    <pre>
import gvsig</pre>
    <pre>from gvsig import geom</pre>
    <pre>
def main(*args):</pre>
    <pre>
    layer = gvsig.currentLayer()</pre>
    <pre>    features = layer.features()</pre>
    <pre>
    #Create schema based on a existing schema</pre>
    <pre>    sch = gvsig.createFeatureType(layer.getSchema())</pre>
    <pre>    #We modified the geometry field of that schema for the geometry type that we want</pre>
    <pre>    sch.getDefaultGeometryAttribute().setGeometryType(geom.CURVE, geom.D3)</pre>
    <pre>
    #new shape</pre>
    <pre>    shp = gvsig.createShape(sch, prefixname="linepol3d")</pre>
    <pre>    </pre>
    <pre>    for feature in features:</pre>
    <pre>        z = float(feature.get("z")) # z field convert to a float number</pre>
    <pre>        g = feature.geometry()</pre>
    <pre>
        # we will create a python list with all the vertexes</pre>
    <pre>        linevertexes = []</pre>
    <pre>        # access to the vertexes of the geometry (line or pol is the same way)</pre>
    <pre>        for vertex in g:</pre>
    <pre>            p1 = geom.createPoint(geom.D3, vertex.getX(), vertex.getY(), z)</pre>
    <pre>            linevertexes.append(p1)</pre>
    <pre>
        # create 3dline with this vertexes</pre>
    <pre>        line3d = geom.createLine(geom.D3, linevertexes)</pre>
    <pre>        print line3d</pre>
    <pre>        </pre>
    <pre>        values = feature.getValues()</pre>
    <pre>        values["GEOMETRY"] = line3d</pre>
    <pre>        </pre>
    <pre>        shp.append(values)</pre>
    <pre>
    shp.commit()</pre>
    <pre>    gvsig.currentView().addLayer(shp)</pre>
    <br>
    <br>
    Best regards,<br>
    Óscar<br>
    <br>
    <div class="moz-cite-prefix">El 12/10/16 a las 14:44, Silvia
      Franceschi escribió:<br>
    </div>
    <blockquote
cite="mid:CABCykqL03T6GZK5WhZYdcoOBrL0hMY_GYY-1ySXLgP=Pyg2jLQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Dear all,
        <div>sorry for asking here, but I can not find any information
          about the possibility to handle 3D vector layers (as
          shapefiles) in gvSIG.</div>
        <div>Is it possible to create/modify a 3D vector layer (point,
          line) in gvSIG?</div>
        <div><br>
        </div>
        <div>I have two types of data to modify:</div>
        <div>- a 2D point layer with a column of z of which I would
          create a 3D point layer</div>
        <div>- a 2D line layer with a column containing the elevation of
          each corner of the line which I would create a 3D line layer.</div>
        <div><br>
        </div>
        <div>Any idea on how I can do?</div>
        <div><br>
        </div>
        <div>Thanks,</div>
        <div><br>
        </div>
        <div>Silvia<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>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Gvsig_internacional mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Gvsig_internacional@listserv.gva.es">Gvsig_internacional@listserv.gva.es</a>

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

<a class="moz-txt-link-freetext" href="https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional">https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>