Hi Óscar, the scripts work fine, many thanks again! May I just ask you one more question? Is there the possibility to remove a feature from a list of features? like featureslist.remove() or something like that? I tried with remove and delete but it seems that these do not exist, any idea?
Is there a way to know which functions are implemented for each feature type in gvSIG scripting? Thanks Silvia On Thu, Oct 13, 2016 at 6:25 PM, Silvia Franceschi < silvia.frances...@gmail.com> wrote: > Thank you Óscar, > to tell you the truth I started to use currentLayer but, since I need to > work with two layers I didn't know how to do and tried to load data from > files. > 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. > > I was following the documentation you linked, it is very useful to start > to get familiar with the scripting environment, thanks! > > I will try the scripts you sent to me and let you know if I will solve my > problems. > > Thank you very much for the quick answer! > > Silvia > > > > > On Thu, Oct 13, 2016 at 6:00 PM, Óscar Martínez <omarti...@gvsig.com> > wrote: > >> Hi! >> >> If i understood correctly, you don't need to use the getSchema function. >> I'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't understand some part of the script i can explain it better. Some help >> is inside the script, step by step. >> >> I recommend to you to start learning scripting using the functions >> currentLayer() (current layer selection in the table of contents) or >> currentView().getLayer("layername") instead of using loadShapeFile >> everytime. It's easier if you just have a loaded layer in your view and >> access to each one each layer with currentLayer o getLayer. >> >> 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: >> >> Access to features: http://downloads.gvsig.org/dow >> nload/web/html/es/scripting_devel_guide/2.3/acceso_a_objetos.html#entidad >> >> Spatial operations: http://downloads.gvsig.org/dow >> nload/web/html/es/scripting_devel_guide/2.3/modulo_geom. >> html#operaciones-espaciales >> >> Current functions: http://downloads.gvsig.org/dow >> nload/web/html/es/scripting_devel_guide/2.3/acceso_a_objetos.html >> >> >> Any trouble here we are! >> >> >> Best regards, >> >> Óscar >> >> >> >> Script (layers of this test are in EPSG:25830) (feature AREA1 is a >> multipolygon): >> >> # encoding: utf-8 >> >> import gvsig >> >> def main(*args): >> # You need to have one view with to layers opened on it >> # The name of the layers will be the name that appear >> # in the table of contents of the view >> >> # To access to the layers that are already loaded in gvSIG >> # gvsig.currentView() give us access to the opened view >> # gvsig.currentView().getLayer(name) give us access a specified layer >> points = gvsig.currentView().getLayer("points") >> area = gvsig.currentView().getLayer("area") >> >> # Access to the features >> features_points = points.features() >> features_area = area.features() >> >> # if you want access to a selection of features, not all >> # you will have to change `features()` with `getSelection()` >> #features_points = points.getSelection() >> #features_area = area.getSelection() >> >> for farea in features_area: >> print "\nChecking : ", farea.get("localId") >> geom_farea = farea.geometry() >> >> #for each area, check all points without intersection >> for fpoint in features_points: >> geom_fpoint = fpoint.geometry() >> >> if not geom_farea.intersects(geom_fpoint): >> print "\tArea: ", farea.get("localId"), " intersects with >> :", fpoint.get("ID") >> # work with the feature >> >> Console output: >> >> Running script testing_silvia_intersec. >> >> Checking : AREA1 >> Area: AREA1 intersects with : 101 >> Area: AREA1 intersects with : 102 >> Area: AREA1 intersects with : 103 >> Area: AREA1 intersects with : 107 >> >> Checking : AREA2 >> Area: AREA2 intersects with : 103 >> Area: AREA2 intersects with : 104 >> Area: AREA2 intersects with : 105 >> Area: AREA2 intersects with : 106 >> Area: AREA2 intersects with : 107 >> Area: AREA2 intersects with : 108 >> Script testing_silvia_intersec terminated. >> >> >> >> El 13/10/16 a las 15:05, Silvia Franceschi escribió: >> >> Hi all, >> 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. >> 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. >> 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. >> Do you have any idea on how to obtain the schema from a vector layer >> selected using the filechooser? >> >> Thanks in advance for any help! >> >> Silvia >> >> >> -- >> ing. Silvia Franceschi >> Via Latemar, 22 >> 38030 Castello di Fiemme (TN) >> >> tel: 0039 -3384501332 >> >> >> _______________________________________________ >> Gvsig_internacional mailing listgvsig_internacio...@listserv.gva.es >> >> To see the archives, edit your preferences or unsubscribe from this mailing >> list, please access this url: >> https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional >> >> >> >> _______________________________________________ >> Gvsig_internacional mailing list >> Gvsig_internacional@listserv.gva.es >> >> To see the archives, edit your preferences or unsubscribe from this >> mailing list, please access this url: >> >> https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional >> >> > > > -- > ing. Silvia Franceschi > Via Latemar, 22 > 38030 Castello di Fiemme (TN) > > tel: 0039 -3384501332 > -- ing. Silvia Franceschi Via Latemar, 22 38030 Castello di Fiemme (TN) tel: 0039 -3384501332
_______________________________________________ Gvsig_internacional mailing list Gvsig_internacional@listserv.gva.es To see the archives, edit your preferences or unsubscribe from this mailing list, please access this url: https://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional