from gvsig import * from geom import * def main(): """Joining points on a line""" #DATA: #input: layer type POINT with points #output: layer type LINE, one line with all the points features = currentLayer().features() #new geometry LINE geom = createGeometry(LINE) #for: each geometry (point) adds to new geometry LINE for i in features: point = i.geometry() #if we create the points from other source... #We can use something like this """ #coordinates of the point x = i.geometry().getX() y = i.geometry().getY() point = createPoint(x,y) """ #add as a vertex of our new geometry geom.addVertex(point) #new feature values = dict() values["ID"]=101 values["CODE"]="line" values["GEOMETRY"]=geom #new Layer namelayer = "line_02.shp" newLayer = createLayer(namelayer) #add values to the new layer newLayer.append(values) #save,close and add to the view newLayer.commit() currentView().addLayer(newLayer) def createLayer(namelayer): path = "C:/gvsig/" + namelayer + ".shp" CRS = currentProject().getProjectionCode() schema = createSchema() schema.append("ID","INTEGER", size=7, default=0) schema.append("CODE", "STRING", size=5, default="m") schema.append("GEOMETRY", "GEOMETRY") output = createShape ( schema, path, CRS=CRS,geometryType= LINE) #return the layer return output