<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hola!</p>
<p>El problema es la ruta de la capa. Te adjunto un script que
puedes ejecutar y que voy explicando paso a paso.</p>
<p>"os.path.dirname(__file__)" es solo para coger ficheros que se
encuentran en la misma carpeta de nuestro script, no es necesario
que lo utilices.</p>
<p>Dejo link a la documentación por si alguien de las listas quiere
consultar esto:
<a class="moz-txt-link-freetext" href="http://downloads.gvsig.org/download/web/html/es/scripting_devel_guide/2.3/cargando_capas.html">http://downloads.gvsig.org/download/web/html/es/scripting_devel_guide/2.3/cargando_capas.html</a></p>
<p>Un saludo,</p>
<p>Óscar<br>
</p>
<p>PD: I've seen today your other emails on the list about
scripting, i will answer you shortly!</p>
<p><br>
</p>
<p>Script:</p>
<p># encoding: utf-8<br>
<br>
import gvsig<br>
import os<br>
from gvsig import commonsdialog<br>
<br>
def main(*args):<br>
<br>
# Get resource path<br>
# shape_path =
os.path.join("D:/lavori_tmp/unibz/2016_06_forlidar/faggio/","aree_faggio_mod.shp")<br>
# is tha same as<br>
shape_path =
"D:/lavori_tmp/unibz/2016_06_forlidar/faggio/aree_faggio_mod.shp"<br>
<br>
print "path shape 2: ", shape_path<br>
<br>
#Check if file exists with os.path exists<br>
print "files exists?: ", os.path.exists(shape_path)<br>
<br>
## File chooser<br>
fc = commonsdialog.filechooser("OPEN_FILE", title="",
initialPath=None, multiselection=False, filter = None,
fileHidingEnabled=True, root=None)<br>
print "filechooser:", fc<br>
print "files exists?: ", os.path.exists(fc)<br>
<br>
# If the file doesnt exist, stop the script<br>
if os.path.exists(fc) == False:<br>
print "Sorry, this file doesn't exist"<br>
return<br>
<br>
# Load layer in gvSIG and add layer to the currentView<br>
# using the crs of the view<br>
shape_1 = gvsig.loadShapeFile(fc)<br>
<br>
# Load layer but is not added to the currentView<br>
shape_2 = gvsig.loadLayer("Shape", shpFile=fc,
CRS="EPSG:32632")</p>
<p> # You can add the layer later<br>
</p>
<p> gvsig.currentView().addLayer(shape_2)<br>
</p>
<br>
<br>
<br>
<div class="moz-cite-prefix">El 13/10/16 a las 16:33, Silvia
Franceschi escribió:<br>
</div>
<blockquote
cite="mid:CABCykqK0t9mt4zBvb7fBQ=cwbHKGBB+V8Rky6j0-UKvvOLV+sw@mail.gmail.com"
type="cite">
<div dir="ltr">Hola,
<div>hay un problema con la lectura de capas vectoriales desde
el entorno de scripting.</div>
<div><br>
</div>
<div>Tengo che trabajar con dos capas (en shapefile) uno con
punto e otro con polygones.</div>
<div><br>
</div>
<div>Estas filas de código me dan error </div>
<div><br>
</div>
<div># Get resource path<br>
</div>
<div>
<div>shape_path =
os.path.join(os.path.dirname(__file__),"D:/lavori_tmp/unibz/2016_06_forlidar/faggio/","aree_faggio_mod.shp")</div>
<div><br>
</div>
<div># loadShapeFile function</div>
<div>s1 = loadShapeFile(shape_path)</div>
<div><br>
</div>
<div># LoadLayer function</div>
<div>areaLayer = loadLayer("Shape", shpFile=s1,
CRS="EPSG:32632")</div>
</div>
<div><br>
</div>
<div>aquí tengo error de RuntimeException: can't load layer
CoercionException.</div>
<div><br>
</div>
<div>Alguien me puede ayudar!</div>
<div><br>
</div>
<div>Saludos y gracias</div>
<div><br>
</div>
<div>Silvia</div>
<div><br>
</div>
<div>PS: disculpe por mi español!!</div>
<div><br>
</div>
<div><br>
-- <br>
<div class="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_usuarios mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gvSIG_usuarios@listserv.gva.es">gvSIG_usuarios@listserv.gva.es</a>
Para ver histórico de mensajes, editar sus preferencias de usuario o darse de baja en esta lista, acuda a la siguiente dirección:
<a class="moz-txt-link-freetext" href="https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_usuarios">https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_usuarios</a>
</pre>
</blockquote>
<br>
</body>
</html>