[Gvsig_usuarios] Problema en la lectura de ficheros da script

Silvia Franceschi silvia.franceschi en gmail.com
Jue Oct 13 18:16:56 CEST 2016


Muchas gracias Óscar,
mañana tengo que probar tus consejos y te haré saber.

Silvia


2016-10-13 17:12 GMT+02:00 Óscar Martínez <omartinez en gvsig.com>:

> Hola!
>
> El problema es la ruta de la capa. Te adjunto un script que puedes
> ejecutar y que voy explicando paso a paso.
>
> "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.
>
> Dejo link a la documentación por si alguien de las listas quiere consultar
> esto: http://downloads.gvsig.org/download/web/html/es/
> scripting_devel_guide/2.3/cargando_capas.html
>
> Un saludo,
>
> Óscar
>
> PD: I've seen today your other emails on the list about scripting, i will
> answer you shortly!
>
>
> Script:
>
> # encoding: utf-8
>
> import gvsig
> import os
> from gvsig import commonsdialog
>
> def main(*args):
>
>     # Get resource path
>     # shape_path = os.path.join("D:/lavori_tmp/
> unibz/2016_06_forlidar/faggio/","aree_faggio_mod.shp")
>     # is tha same as
>     shape_path = "D:/lavori_tmp/unibz/2016_06_forlidar/faggio/aree_faggio_
> mod.shp"
>
>     print "path shape 2: ", shape_path
>
>     #Check if file exists with os.path exists
>     print "files exists?: ", os.path.exists(shape_path)
>
>     ## File chooser
>     fc = commonsdialog.filechooser("OPEN_FILE", title="",
> initialPath=None,  multiselection=False, filter = None,
> fileHidingEnabled=True, root=None)
>     print "filechooser:", fc
>     print "files exists?: ", os.path.exists(fc)
>
>     # If the file doesnt exist, stop the script
>     if os.path.exists(fc) == False:
>         print "Sorry, this file doesn't exist"
>         return
>
>     # Load layer in gvSIG and add layer to the currentView
>     # using the crs of the view
>     shape_1 = gvsig.loadShapeFile(fc)
>
>     # Load layer but is not added to the currentView
>     shape_2 = gvsig.loadLayer("Shape", shpFile=fc, CRS="EPSG:32632")
>
>     # You can add the layer later
>
>     gvsig.currentView().addLayer(shape_2)
>
>
>
> El 13/10/16 a las 16:33, Silvia Franceschi escribió:
>
> Hola,
> hay un problema con la lectura de capas vectoriales desde el entorno de
> scripting.
>
> Tengo che trabajar con dos capas (en shapefile) uno con punto e otro con
> polygones.
>
> Estas filas de código me dan error
>
> # Get resource path
> shape_path = os.path.join(os.path.dirname(__file__),"D:/lavori_tmp/unibz/
> 2016_06_forlidar/faggio/","aree_faggio_mod.shp")
>
> # loadShapeFile function
> s1 = loadShapeFile(shape_path)
>
> # LoadLayer function
> areaLayer = loadLayer("Shape", shpFile=s1, CRS="EPSG:32632")
>
> aquí tengo error de RuntimeException: can't load layer CoercionException.
>
> Alguien me puede ayudar!
>
> Saludos y gracias
>
> Silvia
>
> PS: disculpe por mi español!!
>
>
> --
> ing. Silvia Franceschi
> Via Latemar, 22
> 38030 Castello di Fiemme (TN)
>
> tel: 0039 -3384501332
>
>
> _______________________________________________
> gvSIG_usuarios mailing listgvSIG_usuarios en listserv.gva.es
>
> Para ver histórico de mensajes, editar sus preferencias de usuario o darse de baja en esta lista, acuda a la siguiente dirección:
> https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_usuarios
>
>
>
> _______________________________________________
> gvSIG_usuarios mailing list
> gvSIG_usuarios en listserv.gva.es
>
> Para ver histórico de mensajes, editar sus preferencias de usuario o darse
> de baja en esta lista, acuda a la siguiente dirección:
>
> https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_usuarios
>
>


-- 
ing. Silvia Franceschi
Via Latemar, 22
38030 Castello di Fiemme (TN)

tel: 0039 -3384501332
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listserv.gva.es/pipermail/gvsig_usuarios/attachments/20161013/d5d4b511/attachment.html>


Más información sobre la lista de distribución gvSIG_usuarios