Vertex number ca atribut

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Vertex number ca atribut

geo-spatial.org mailing list
Buna ziua,

Am urmatoarea problema pe care trebuie sa o rezolv in QGIS si cred ca e nu ceva complicat.

Am un shape cu linii din care creez un nou strat de puncte (extract nodes) pana aici totul e OK. Acum as vrea ca pentru stratul de puncte sa calculez un atribut Numar_Pct care sa aiba aceleasi valori cu vertex number de la shapeul de linii.

In global mapper pot face chestia asta cu Index in layer insa as vrea sa pot face acest lucru in qGIS.

Multunesc mult!
Adi
Reply | Threaded
Open this post in threaded view
|

Re: Vertex number ca atribut

geo-spatial.org mailing list
Salut, Adi!
Pentru linii.shp deschizi tabela de atribute si apesi pe calculator. Aici ii dai sa-ti creeze o coloana noua, iar la expresie scrii  num_points(  $geometry ) si apesi ok. Acum o sa ai o coloana unde iti va arata numarul de vertecsi pentru fiecare linie. Apoi executi functia extract nodes si vei vedea ca in tabelul de atribute al stratului de puncte vei avea aceleasi coloane, inclusiv num_points-ul creat anterior.
Mentionez ca rulez QGIS versiunea 2.16.1. Sper sa mearga! 
Numai bine,Mihai

    On Monday, September 12, 2016 10:24 AM, "[hidden email] [geo-spatial]" <[hidden email]> wrote:
 

     Buna ziua,

Am urmatoarea problema pe care trebuie sa o rezolv in QGIS si cred ca e nu ceva complicat.

Am un shape cu linii din care creez un nou strat de puncte (extract nodes) pana aici totul e OK. Acum as vrea ca pentru stratul de puncte sa calculez un atribut Numar_Pct care sa aiba aceleasi valori cu vertex number de la shapeul de linii.

In global mapper pot face chestia asta cu Index in layer insa as vrea sa pot face acest lucru in qGIS.

Multunesc mult!
Adi  #yiv8779093443 #yiv8779093443 -- #yiv8779093443ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv8779093443 #yiv8779093443ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv8779093443 #yiv8779093443ygrp-mkp #yiv8779093443hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv8779093443 #yiv8779093443ygrp-mkp #yiv8779093443ads {margin-bottom:10px;}#yiv8779093443 #yiv8779093443ygrp-mkp .yiv8779093443ad {padding:0 0;}#yiv8779093443 #yiv8779093443ygrp-mkp .yiv8779093443ad p {margin:0;}#yiv8779093443 #yiv8779093443ygrp-mkp .yiv8779093443ad a {color:#0000ff;text-decoration:none;}#yiv8779093443 #yiv8779093443ygrp-sponsor #yiv8779093443ygrp-lc {font-family:Arial;}#yiv8779093443 #yiv8779093443ygrp-sponsor #yiv8779093443ygrp-lc #yiv8779093443hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv8779093443 #yiv8779093443ygrp-sponsor #yiv8779093443ygrp-lc .yiv8779093443ad {margin-bottom:10px;padding:0 0;}#yiv8779093443 #yiv8779093443actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv8779093443 #yiv8779093443activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv8779093443 #yiv8779093443activity span {font-weight:700;}#yiv8779093443 #yiv8779093443activity span:first-child {text-transform:uppercase;}#yiv8779093443 #yiv8779093443activity span a {color:#5085b6;text-decoration:none;}#yiv8779093443 #yiv8779093443activity span span {color:#ff7900;}#yiv8779093443 #yiv8779093443activity span .yiv8779093443underline {text-decoration:underline;}#yiv8779093443 .yiv8779093443attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv8779093443 .yiv8779093443attach div a {text-decoration:none;}#yiv8779093443 .yiv8779093443attach img {border:none;padding-right:5px;}#yiv8779093443 .yiv8779093443attach label {display:block;margin-bottom:5px;}#yiv8779093443 .yiv8779093443attach label a {text-decoration:none;}#yiv8779093443 blockquote {margin:0 0 0 4px;}#yiv8779093443 .yiv8779093443bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv8779093443 .yiv8779093443bold a {text-decoration:none;}#yiv8779093443 dd.yiv8779093443last p a {font-family:Verdana;font-weight:700;}#yiv8779093443 dd.yiv8779093443last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv8779093443 dd.yiv8779093443last p span.yiv8779093443yshortcuts {margin-right:0;}#yiv8779093443 div.yiv8779093443attach-table div div a {text-decoration:none;}#yiv8779093443 div.yiv8779093443attach-table {width:400px;}#yiv8779093443 div.yiv8779093443file-title a, #yiv8779093443 div.yiv8779093443file-title a:active, #yiv8779093443 div.yiv8779093443file-title a:hover, #yiv8779093443 div.yiv8779093443file-title a:visited {text-decoration:none;}#yiv8779093443 div.yiv8779093443photo-title a, #yiv8779093443 div.yiv8779093443photo-title a:active, #yiv8779093443 div.yiv8779093443photo-title a:hover, #yiv8779093443 div.yiv8779093443photo-title a:visited {text-decoration:none;}#yiv8779093443 div#yiv8779093443ygrp-mlmsg #yiv8779093443ygrp-msg p a span.yiv8779093443yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv8779093443 .yiv8779093443green {color:#628c2a;}#yiv8779093443 .yiv8779093443MsoNormal {margin:0 0 0 0;}#yiv8779093443 o {font-size:0;}#yiv8779093443 #yiv8779093443photos div {float:left;width:72px;}#yiv8779093443 #yiv8779093443photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv8779093443 #yiv8779093443photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv8779093443 #yiv8779093443reco-category {font-size:77%;}#yiv8779093443 #yiv8779093443reco-desc {font-size:77%;}#yiv8779093443 .yiv8779093443replbq {margin:4px;}#yiv8779093443 #yiv8779093443ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv8779093443 #yiv8779093443ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv8779093443 #yiv8779093443ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv8779093443 #yiv8779093443ygrp-mlmsg select, #yiv8779093443 input, #yiv8779093443 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv8779093443 #yiv8779093443ygrp-mlmsg pre, #yiv8779093443 code {font:115% monospace;}#yiv8779093443 #yiv8779093443ygrp-mlmsg * {line-height:1.22em;}#yiv8779093443 #yiv8779093443ygrp-mlmsg #yiv8779093443logo {padding-bottom:10px;}#yiv8779093443 #yiv8779093443ygrp-msg p a {font-family:Verdana;}#yiv8779093443 #yiv8779093443ygrp-msg p#yiv8779093443attach-count span {color:#1E66AE;font-weight:700;}#yiv8779093443 #yiv8779093443ygrp-reco #yiv8779093443reco-head {color:#ff7900;font-weight:700;}#yiv8779093443 #yiv8779093443ygrp-reco {margin-bottom:20px;padding:0px;}#yiv8779093443 #yiv8779093443ygrp-sponsor #yiv8779093443ov li a {font-size:130%;text-decoration:none;}#yiv8779093443 #yiv8779093443ygrp-sponsor #yiv8779093443ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv8779093443 #yiv8779093443ygrp-sponsor #yiv8779093443ov ul {margin:0;padding:0 0 0 8px;}#yiv8779093443 #yiv8779093443ygrp-text {font-family:Georgia;}#yiv8779093443 #yiv8779093443ygrp-text p {margin:0 0 1em 0;}#yiv8779093443 #yiv8779093443ygrp-text tt {font-size:120%;}#yiv8779093443 #yiv8779093443ygrp-vital ul li:last-child {border-right:none !important;}#yiv8779093443

   
Reply | Threaded
Open this post in threaded view
|

Re: Vertex number ca atribut

geo-spatial.org mailing list
Salut Mihai,

Mersi mult de raspuns. Nu este chiar ce cautam. Mai jos incerc sa descriu mai detaliat ce as vrea sa obtin.

Am un shp cu linii in qgis. In modul de editare in Qgis in momentul cand am selectat o liniei pot sa vad toti vertecsi acesteia. Vertecsi sunt numerotati de la 0 la n. In momentul in care rulez extract nodes si creez stratul de puncte as vrea ca primul punct creat sa aiba numarul 0 nu 1.  

 Deci dupa extract nodes trebuie sa calculez un atribut numar punct. Default Qgis-ul imi pune pentru pirmul punct numarul 1 insa as vrea sa imi pastreze 0. In orice caz pentru asta adaug minus 1 la acesta operatiune si am rezolvat-o.
 Dar problema cu care am ramas este urmatoarea:

Eu in shape-ul cu linii am mai multe linii si as vrea (dar nu stiu daca se poate) sa creez aceste puncte pentru toate liniile dar sa imi pastreze numerotarea pentru fiecare linie in parte.

In acest moment Qgis imi ia prima liniei si creaza punctele de la 1 la n iar la urmatoare liniei incepe de la n+1 pana la n+n. Eu as vrea ca in momentul cand creaza punctele pentru linia 2 sa inceapa din nou de la 1 si asa mai departe.

Deocamdata fac acest lucru ruland extract nodes pe fiecare liniei in parte.

Probabil ca ar trebuie sa caut un scrip ceva care sa tina cont si de un atribut ID linie sa zicem iar in momentul in care acesta se schimba sa stie ca trebuie sa inceapa din nou numerotarea de la 1.

Va trebui sa ma consult cu domnu'Google daca o sa gasesc un raspuns o sa revin.

Multumesc!
Adi
 

 

 
 


Reply | Threaded
Open this post in threaded view
|

Re: Vertex number ca atribut

geo-spatial.org mailing list
Salut!
Am facut un scipt pentru problema ta!
Acum, deschide te rog QGIS, apasa alt+ctrl+P ca sa deschizi consola python.Adauga-ti layer-ul cu linii in proiect. Sa vezi ce proiectie are. Seteaza proiectia proiectului la fel.Deschide in notepad++ txt-ul atasat in mail. Schimba in cod proiectia (3844) in ceea ce ai tu, localizarea unde vrei sa-ti pui fisierul nou creat cu puncte "D:\etc...".Selecteaza tot codul, da-i copy paste dupa cele 3 sageti >>>Acum ti-a creat stratul.Apesi enter, pana iti pune punctele pe harta.Te duci in tabela de atribute a punctelor si creezi o coloana noua, fiindca numerele create de mine sunt de fapt text, nu numar. Pentru asta deschizi calculatorul, apesi "create a new field", ii dai un nume coloanei si la expresie scrii  to_int( "ID" ). Poti sa stergi vechea coloana.Da-mi un semn.
Mihai

 

    On Monday, September 19, 2016 11:21 AM, "[hidden email] [geo-spatial]" <[hidden email]> wrote:
 

     Salut Mihai,

Mersi mult de raspuns. Nu este chiar ce cautam. Mai jos incerc sa descriu mai detaliat ce as vrea sa obtin.

Am un shp cu linii in qgis. In modul de editare in Qgis in momentul cand am selectat o liniei pot sa vad toti vertecsi acesteia. Vertecsi sunt numerotati de la 0 la n. In momentul in care rulez extract nodes si creez stratul de puncte as vrea ca primul punct creat sa aiba numarul 0 nu 1. 
Deci dupa extract nodes trebuie sa calculez un atribut numar punct. Default Qgis-ul imi pune pentru pirmul punct numarul 1 insa as vrea sa imi pastreze 0. In orice caz pentru asta adaug minus 1 la acesta operatiune si am rezolvat-o.Dar problema cu care am ramas este urmatoarea:

Eu in shape-ul cu linii am mai multe linii si as vrea (dar nu stiu daca se poate) sa creez aceste puncte pentru toate liniile dar sa imi pastreze numerotarea pentru fiecare linie in parte.

In acest moment Qgis imi ia prima liniei si creaza punctele de la 1 la n iar la urmatoare liniei incepe de la n+1 pana la n+n. Eu as vrea ca in momentul cand creaza punctele pentru linia 2 sa inceapa din nou de la 1 si asa mai departe.

Deocamdata fac acest lucru ruland extract nodes pe fiecare liniei in parte.

Probabil ca ar trebuie sa caut un scrip ceva care sa tina cont si de un atribut ID linie sa zicem iar in momentul in care acesta se schimba sa stie ca trebuie sa inceapa din nou numerotarea de la 1.

Va trebui sa ma consult cu domnu'Google daca o sa gasesc un raspuns o sa revin.

Multumesc!
Adi



  #yiv1292598491 #yiv1292598491 -- #yiv1292598491ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv1292598491 #yiv1292598491ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv1292598491 #yiv1292598491ygrp-mkp #yiv1292598491hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv1292598491 #yiv1292598491ygrp-mkp #yiv1292598491ads {margin-bottom:10px;}#yiv1292598491 #yiv1292598491ygrp-mkp .yiv1292598491ad {padding:0 0;}#yiv1292598491 #yiv1292598491ygrp-mkp .yiv1292598491ad p {margin:0;}#yiv1292598491 #yiv1292598491ygrp-mkp .yiv1292598491ad a {color:#0000ff;text-decoration:none;}#yiv1292598491 #yiv1292598491ygrp-sponsor #yiv1292598491ygrp-lc {font-family:Arial;}#yiv1292598491 #yiv1292598491ygrp-sponsor #yiv1292598491ygrp-lc #yiv1292598491hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv1292598491 #yiv1292598491ygrp-sponsor #yiv1292598491ygrp-lc .yiv1292598491ad {margin-bottom:10px;padding:0 0;}#yiv1292598491 #yiv1292598491actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv1292598491 #yiv1292598491activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv1292598491 #yiv1292598491activity span {font-weight:700;}#yiv1292598491 #yiv1292598491activity span:first-child {text-transform:uppercase;}#yiv1292598491 #yiv1292598491activity span a {color:#5085b6;text-decoration:none;}#yiv1292598491 #yiv1292598491activity span span {color:#ff7900;}#yiv1292598491 #yiv1292598491activity span .yiv1292598491underline {text-decoration:underline;}#yiv1292598491 .yiv1292598491attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv1292598491 .yiv1292598491attach div a {text-decoration:none;}#yiv1292598491 .yiv1292598491attach img {border:none;padding-right:5px;}#yiv1292598491 .yiv1292598491attach label {display:block;margin-bottom:5px;}#yiv1292598491 .yiv1292598491attach label a {text-decoration:none;}#yiv1292598491 blockquote {margin:0 0 0 4px;}#yiv1292598491 .yiv1292598491bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv1292598491 .yiv1292598491bold a {text-decoration:none;}#yiv1292598491 dd.yiv1292598491last p a {font-family:Verdana;font-weight:700;}#yiv1292598491 dd.yiv1292598491last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv1292598491 dd.yiv1292598491last p span.yiv1292598491yshortcuts {margin-right:0;}#yiv1292598491 div.yiv1292598491attach-table div div a {text-decoration:none;}#yiv1292598491 div.yiv1292598491attach-table {width:400px;}#yiv1292598491 div.yiv1292598491file-title a, #yiv1292598491 div.yiv1292598491file-title a:active, #yiv1292598491 div.yiv1292598491file-title a:hover, #yiv1292598491 div.yiv1292598491file-title a:visited {text-decoration:none;}#yiv1292598491 div.yiv1292598491photo-title a, #yiv1292598491 div.yiv1292598491photo-title a:active, #yiv1292598491 div.yiv1292598491photo-title a:hover, #yiv1292598491 div.yiv1292598491photo-title a:visited {text-decoration:none;}#yiv1292598491 div#yiv1292598491ygrp-mlmsg #yiv1292598491ygrp-msg p a span.yiv1292598491yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv1292598491 .yiv1292598491green {color:#628c2a;}#yiv1292598491 .yiv1292598491MsoNormal {margin:0 0 0 0;}#yiv1292598491 o {font-size:0;}#yiv1292598491 #yiv1292598491photos div {float:left;width:72px;}#yiv1292598491 #yiv1292598491photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv1292598491 #yiv1292598491photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv1292598491 #yiv1292598491reco-category {font-size:77%;}#yiv1292598491 #yiv1292598491reco-desc {font-size:77%;}#yiv1292598491 .yiv1292598491replbq {margin:4px;}#yiv1292598491 #yiv1292598491ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv1292598491 #yiv1292598491ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv1292598491 #yiv1292598491ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv1292598491 #yiv1292598491ygrp-mlmsg select, #yiv1292598491 input, #yiv1292598491 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv1292598491 #yiv1292598491ygrp-mlmsg pre, #yiv1292598491 code {font:115% monospace;}#yiv1292598491 #yiv1292598491ygrp-mlmsg * {line-height:1.22em;}#yiv1292598491 #yiv1292598491ygrp-mlmsg #yiv1292598491logo {padding-bottom:10px;}#yiv1292598491 #yiv1292598491ygrp-msg p a {font-family:Verdana;}#yiv1292598491 #yiv1292598491ygrp-msg p#yiv1292598491attach-count span {color:#1E66AE;font-weight:700;}#yiv1292598491 #yiv1292598491ygrp-reco #yiv1292598491reco-head {color:#ff7900;font-weight:700;}#yiv1292598491 #yiv1292598491ygrp-reco {margin-bottom:20px;padding:0px;}#yiv1292598491 #yiv1292598491ygrp-sponsor #yiv1292598491ov li a {font-size:130%;text-decoration:none;}#yiv1292598491 #yiv1292598491ygrp-sponsor #yiv1292598491ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv1292598491 #yiv1292598491ygrp-sponsor #yiv1292598491ov ul {margin:0;padding:0 0 0 8px;}#yiv1292598491 #yiv1292598491ygrp-text {font-family:Georgia;}#yiv1292598491 #yiv1292598491ygrp-text p {margin:0 0 1em 0;}#yiv1292598491 #yiv1292598491ygrp-text tt {font-size:120%;}#yiv1292598491 #yiv1292598491ygrp-vital ul li:last-child {border-right:none !important;}#yiv1292598491

   
  ----------

from qgis.core import QgsVectorLayer, QgsField, QgsMapLayerRegistry  
from PyQt4.QtCore import QVariant
from qgis import *
from qgis.utils import *

def extractPoints( geom ):
    multi_geom = QgsGeometry()
    temp_geom = []
    if geom.type() == 0: # it's a point
        if geom.isMultipart():
            temp_geom = geom.asMultiPoint()
        else:
            temp_geom.append(geom.asPoint())
    elif geom.type() == 1: # it's a line
        if geom.isMultipart():
            multi_geom = geom.asMultiPolyline() #multi_geog is a multiline
            for i in multi_geom: #i is a line
                temp_geom.extend( i )
        else:
            temp_geom = geom.asPolyline()
    elif geom.type() == 2: # it's a polygon
        if geom.isMultipart():
            multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon
            for i in multi_geom: #i is a polygon
                for j in i: #j is a line
                    temp_geom.extend( j )
        else:
            multi_geom = geom.asPolygon() #multi_geom is a polygon
            for i in multi_geom: #i is a line
                temp_geom.extend( i )
    # FIXME - if there is none of know geoms (point, line, polygon) show an warning message
    return temp_geom

def refresh_layers():
    for layer in qgis.utils.iface.mapCanvas().layers():
        layer.triggerRepaint()

def creare_puncte():
    pointLayer = QgsVectorLayer("Point", "puncte", "memory")
    pointLayer.startEditing()  
    layerData = pointLayer.dataProvider()
    layerData.addAttributes([ QgsField("ID", QVariant.LongLong)])
    pointLayer.commitChanges()
    layer=QgsMapLayerRegistry.instance().mapLayers().values()[0]
    layer_features=layer.getFeatures()
    for feature in layer_features:
        geom=feature.geometry()
        i=0
        points = extractPoints(geom)
        for point in points:
            feat = QgsFeature(layer.pendingFields())    
            feat.setAttribute(0, long(i))
            feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(point)))
            (res, outFeats) = pointLayer.dataProvider().addFeatures([feat])
            i=i+1
            print(res,outFeats)

def adaugare_puncte():
    _writer = QgsVectorFileWriter.writeAsVectorFormat(pointLayer,r"D:\mmihai\Geo-spatial\puncte.shp","utf-8",None,"ESRI Shapefile")
    iface.addVectorLayer("D:/mmihai/Geo-spatial/puncte.shp", "puncte", "ogr")
    qgis.utils.iface.activeLayer().setCrs(QgsCoordinateReferenceSystem(3844, QgsCoordinateReferenceSystem.EpsgCrsId))
    qgis.utils.iface.activeLayer().setProviderEncoding(u'UTF-8')
    refresh_layers()                                              
                                                     

creare_puncte()
adaugare_puncte()


[Non-text portions of this message have been removed]



------------------------------------
Posted by: Mihai-Mircea Moise <[hidden email]>
------------------------------------


------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/geo-spatial/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/geo-spatial/join
    (Yahoo! ID required)

<*> To change settings via email:
    [hidden email]
    [hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Reply | Threaded
Open this post in threaded view
|

Re: Vertex number ca atribut

geo-spatial.org mailing list
Salut Mihai,

Multumesc foarte mult pentru ajutor insa nu am reusit sa rulez scriptul fara erori.

Mai jos sunt rezultatele obtinute:

 from qgis.core import QgsVectorLayer, QgsField, QgsMapLayerRegistry
 from PyQt4.QtCore import QVariant
 from qgis import *
 from qgis.utils import *
 def extractPoints( geom ):
 multi_geom = QgsGeometry()
   File "<input>", line 2
     multi_geom = QgsGeometry()
              ^
 IndentationError: expected an indented block
 temp_geom = []
 if geom.type() == 0: # it's a point
 if geom.isMultipart():
   File "<input>", line 2
     if geom.isMultipart():
      ^
 IndentationError: expected an indented block
 temp_geom = geom.asMultiPoint()
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'geom' is not defined
 else:
   File "<input>", line 1
     else:
        ^
 SyntaxError: invalid syntax
 temp_geom.append(geom.asPoint())
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'geom' is not defined
 elif geom.type() == 1: # it's a line
   File "<input>", line 1
     elif geom.type() == 1: # it's a line
        ^
 SyntaxError: invalid syntax
 if geom.isMultipart():
 multi_geom = geom.asMultiPolyline() #multi_geog is a multiline
   File "<input>", line 2
     multi_geom = geom.asMultiPolyline() #multi_geog is a multiline
              ^
 IndentationError: expected an indented block
 for i in multi_geom: #i is a line
 temp_geom.extend( i )
   File "<input>", line 2
     temp_geom.extend( i )
             ^
 IndentationError: expected an indented block
 else:
   File "<input>", line 1
     else:
        ^
 SyntaxError: invalid syntax
 temp_geom = geom.asPolyline()
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'geom' is not defined
 elif geom.type() == 2: # it's a polygon
   File "<input>", line 1
     elif geom.type() == 2: # it's a polygon
        ^
 SyntaxError: invalid syntax
 if geom.isMultipart():
 multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon
   File "<input>", line 2
     multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon
              ^
 IndentationError: expected an indented block
 for i in multi_geom: #i is a polygon
 for j in i: #j is a line
   File "<input>", line 2
     for j in i: #j is a line
       ^
 IndentationError: expected an indented block
 temp_geom.extend( j )
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'j' is not defined
 else:
   File "<input>", line 1
     else:
        ^
 SyntaxError: invalid syntax
 multi_geom = geom.asPolygon() #multi_geom is a polygon
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'geom' is not defined
 for i in multi_geom: #i is a line
 temp_geom.extend( i )
   File "<input>", line 2
     temp_geom.extend( i )
             ^
 IndentationError: expected an indented block
 # FIXME - if there is none of know geoms (point, line, polygon) show an warning message
 return temp_geom
   File "<input>", line 1
 SyntaxError: 'return' outside function
 def refresh_layers():
 for layer in qgis.utils.iface.mapCanvas().layers():
   File "<input>", line 2
     for layer in qgis.utils.iface.mapCanvas().layers():
       ^
 IndentationError: expected an indented block
 layer.triggerRepaint()
 def creare_puncte():
 pointLayer = QgsVectorLayer("Point", "puncte", "memory")
   File "<input>", line 2
     pointLayer = QgsVectorLayer("Point", "puncte", "memory")
              ^
 IndentationError: expected an indented block
 pointLayer.startEditing()
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'pointLayer' is not defined
 layerData = pointLayer.dataProvider()
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'pointLayer' is not defined
 layerData.addAttributes([ QgsField("ID", QVariant.LongLong)])
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'layerData' is not defined
 pointLayer.commitChanges()
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'pointLayer' is not defined
 layer=QgsMapLayerRegistry.instance().mapLayers().values()[0]
 layer_features=layer.getFeatures()
 for feature in layer_features:
 geom=feature.geometry()
   File "<input>", line 2
     geom=feature.geometry()
        ^
 IndentationError: expected an indented block
 i=0
 points = extractPoints(geom)
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'extractPoints' is not defined
 for point in points:
 feat = QgsFeature(layer.pendingFields())
   File "<input>", line 2
     feat = QgsFeature(layer.pendingFields())
        ^
 IndentationError: expected an indented block
 feat.setAttribute(0, long(i))
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'feat' is not defined
 feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(point)))
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'feat' is not defined
 (res, outFeats) = pointLayer.dataProvider().addFeatures([feat])
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'pointLayer' is not defined
 i=i+1
 print(res,outFeats)
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'res' is not defined
 def adaugare_puncte():
 _writer = QgsVectorFileWriter.writeAsVectorFormat(pointLayer,r"D:\puncte.shp","utf-8",None,"ESRI Shapefile")
   File "<input>", line 2
     _writer = QgsVectorFileWriter.writeAsVectorFormat(pointLayer,r"D:\puncte.shp","utf-8",None,"ESRI Shapefile")
           ^
 IndentationError: expected an indented block
 iface.addVectorLayer("D:/puncte.shp", "puncte", "ogr")
 <qgis._core.QgsVectorLayer object at 0x000000001B18B9D8>
 qgis.utils.iface.activeLayer().setCrs(QgsCoordinateReferenceSystem(3844, QgsCoordinateReferenceSystem.EpsgCrsId))
 qgis.utils.iface.activeLayer().setProviderEncoding(u'UTF-8')
 refresh_layers()
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'refresh_layers' is not defined
 creare_puncte()
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'creare_puncte' is not defined
 adaugare_puncte()
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 NameError: name 'adaugare_puncte' is not defined

 

Reply | Threaded
Open this post in threaded view
|

Re: Vertex number ca atribut

geo-spatial.org mailing list
bun, atunci instaleaza-ti team viewer te rog si trimite-mi id-ul si parola taintru eu personal sa vad care-i baiul.

    On Tuesday, September 20, 2016 8:55 AM, "[hidden email] [geo-spatial]" <[hidden email]> wrote:
 

     Salut Mihai,

Multumesc foarte mult pentru ajutor insa nu am reusit sa rulez scriptul fara erori.

Mai jos sunt rezultatele obtinute:
from qgis.core import QgsVectorLayer, QgsField, QgsMapLayerRegistry from PyQt4.QtCore import QVariant from qgis import * from qgis.utils import * def extractPoints( geom ): multi_geom = QgsGeometry()   File "<input>", line 2    multi_geom = QgsGeometry()             ^IndentationError: expected an indented blocktemp_geom = [] if geom.type() == 0: # it's a point if geom.isMultipart():   File "<input>", line 2    if geom.isMultipart():     ^IndentationError: expected an indented blocktemp_geom = geom.asMultiPoint() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'geom' is not definedelse:   File "<input>", line 1    else:       ^SyntaxError: invalid syntaxtemp_geom.append(geom.asPoint()) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'geom' is not definedelif geom.type() == 1: # it's a line   File "<input>", line 1    elif geom.type() == 1: # it's a line       ^SyntaxError: invalid syntaxif geom.isMultipart(): multi_geom = geom.asMultiPolyline() #multi_geog is a multiline   File "<input>", line 2    multi_geom = geom.asMultiPolyline() #multi_geog is a multiline             ^IndentationError: expected an indented blockfor i in multi_geom: #i is a line temp_geom.extend( i )   File "<input>", line 2    temp_geom.extend( i )            ^IndentationError: expected an indented blockelse:   File "<input>", line 1    else:       ^SyntaxError: invalid syntaxtemp_geom = geom.asPolyline() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'geom' is not definedelif geom.type() == 2: # it's a polygon   File "<input>", line 1    elif geom.type() == 2: # it's a polygon       ^SyntaxError: invalid syntaxif geom.isMultipart(): multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon   File "<input>", line 2    multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon             ^IndentationError: expected an indented blockfor i in multi_geom: #i is a polygon for j in i: #j is a line   File "<input>", line 2    for j in i: #j is a line      ^IndentationError: expected an indented blocktemp_geom.extend( j ) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'j' is not definedelse:   File "<input>", line 1    else:       ^SyntaxError: invalid syntaxmulti_geom = geom.asPolygon() #multi_geom is a polygon Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'geom' is not definedfor i in multi_geom: #i is a line temp_geom.extend( i )   File "<input>", line 2    temp_geom.extend( i )            ^IndentationError: expected an indented block# FIXME - if there is none of know geoms (point, line, polygon) show an warning message return temp_geom   File "<input>", line 1SyntaxError: 'return' outside functiondef refresh_layers(): for layer in qgis.utils.iface.mapCanvas().layers():   File "<input>", line 2    for layer in qgis.utils.iface.mapCanvas().layers():      ^IndentationError: expected an indented blocklayer.triggerRepaint() def creare_puncte(): pointLayer = QgsVectorLayer("Point", "puncte", "memory")   File "<input>", line 2    pointLayer = QgsVectorLayer("Point", "puncte", "memory")             ^IndentationError: expected an indented blockpointLayer.startEditing() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'pointLayer' is not definedlayerData = pointLayer.dataProvider() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'pointLayer' is not definedlayerData.addAttributes([ QgsField("ID", QVariant.LongLong)]) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'layerData' is not definedpointLayer.commitChanges() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'pointLayer' is not definedlayer=QgsMapLayerRegistry.instance().mapLayers().values()[0] layer_features=layer.getFeatures() for feature in layer_features: geom=feature.geometry()   File "<input>", line 2    geom=feature.geometry()       ^IndentationError: expected an indented blocki=0 points = extractPoints(geom) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'extractPoints' is not definedfor point in points: feat = QgsFeature(layer.pendingFields())   File "<input>", line 2    feat = QgsFeature(layer.pendingFields())       ^IndentationError: expected an indented blockfeat.setAttribute(0, long(i)) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'feat' is not definedfeat.setGeometry(QgsGeometry.fromPoint(QgsPoint(point))) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'feat' is not defined(res, outFeats) = pointLayer.dataProvider().addFeatures([feat]) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'pointLayer' is not definedi=i+1 print(res,outFeats) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'res' is not defineddef adaugare_puncte(): _writer = QgsVectorFileWriter.writeAsVectorFormat(pointLayer,r"D:\puncte.shp","utf-8",None,"ESRI Shapefile")   File "<input>", line 2    _writer = QgsVectorFileWriter.writeAsVectorFormat(pointLayer,r"D:\puncte.shp","utf-8",None,"ESRI Shapefile")          ^IndentationError: expected an indented blockiface.addVectorLayer("D:/puncte.shp", "puncte", "ogr") <qgis._core.QgsVectorLayer object at 0x000000001B18B9D8>qgis.utils.iface.activeLayer().setCrs(QgsCoordinateReferenceSystem(3844, QgsCoordinateReferenceSystem.EpsgCrsId)) qgis.utils.iface.activeLayer().setProviderEncoding(u'UTF-8') refresh_layers() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'refresh_layers' is not definedcreare_puncte() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'creare_puncte' is not definedadaugare_puncte() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'adaugare_puncte' is not defined
  #yiv7424696027 #yiv7424696027 -- #yiv7424696027ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv7424696027 #yiv7424696027ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv7424696027 #yiv7424696027ygrp-mkp #yiv7424696027hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv7424696027 #yiv7424696027ygrp-mkp #yiv7424696027ads {margin-bottom:10px;}#yiv7424696027 #yiv7424696027ygrp-mkp .yiv7424696027ad {padding:0 0;}#yiv7424696027 #yiv7424696027ygrp-mkp .yiv7424696027ad p {margin:0;}#yiv7424696027 #yiv7424696027ygrp-mkp .yiv7424696027ad a {color:#0000ff;text-decoration:none;}#yiv7424696027 #yiv7424696027ygrp-sponsor #yiv7424696027ygrp-lc {font-family:Arial;}#yiv7424696027 #yiv7424696027ygrp-sponsor #yiv7424696027ygrp-lc #yiv7424696027hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv7424696027 #yiv7424696027ygrp-sponsor #yiv7424696027ygrp-lc .yiv7424696027ad {margin-bottom:10px;padding:0 0;}#yiv7424696027 #yiv7424696027actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv7424696027 #yiv7424696027activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv7424696027 #yiv7424696027activity span {font-weight:700;}#yiv7424696027 #yiv7424696027activity span:first-child {text-transform:uppercase;}#yiv7424696027 #yiv7424696027activity span a {color:#5085b6;text-decoration:none;}#yiv7424696027 #yiv7424696027activity span span {color:#ff7900;}#yiv7424696027 #yiv7424696027activity span .yiv7424696027underline {text-decoration:underline;}#yiv7424696027 .yiv7424696027attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv7424696027 .yiv7424696027attach div a {text-decoration:none;}#yiv7424696027 .yiv7424696027attach img {border:none;padding-right:5px;}#yiv7424696027 .yiv7424696027attach label {display:block;margin-bottom:5px;}#yiv7424696027 .yiv7424696027attach label a {text-decoration:none;}#yiv7424696027 blockquote {margin:0 0 0 4px;}#yiv7424696027 .yiv7424696027bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv7424696027 .yiv7424696027bold a {text-decoration:none;}#yiv7424696027 dd.yiv7424696027last p a {font-family:Verdana;font-weight:700;}#yiv7424696027 dd.yiv7424696027last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv7424696027 dd.yiv7424696027last p span.yiv7424696027yshortcuts {margin-right:0;}#yiv7424696027 div.yiv7424696027attach-table div div a {text-decoration:none;}#yiv7424696027 div.yiv7424696027attach-table {width:400px;}#yiv7424696027 div.yiv7424696027file-title a, #yiv7424696027 div.yiv7424696027file-title a:active, #yiv7424696027 div.yiv7424696027file-title a:hover, #yiv7424696027 div.yiv7424696027file-title a:visited {text-decoration:none;}#yiv7424696027 div.yiv7424696027photo-title a, #yiv7424696027 div.yiv7424696027photo-title a:active, #yiv7424696027 div.yiv7424696027photo-title a:hover, #yiv7424696027 div.yiv7424696027photo-title a:visited {text-decoration:none;}#yiv7424696027 div#yiv7424696027ygrp-mlmsg #yiv7424696027ygrp-msg p a span.yiv7424696027yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv7424696027 .yiv7424696027green {color:#628c2a;}#yiv7424696027 .yiv7424696027MsoNormal {margin:0 0 0 0;}#yiv7424696027 o {font-size:0;}#yiv7424696027 #yiv7424696027photos div {float:left;width:72px;}#yiv7424696027 #yiv7424696027photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv7424696027 #yiv7424696027photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv7424696027 #yiv7424696027reco-category {font-size:77%;}#yiv7424696027 #yiv7424696027reco-desc {font-size:77%;}#yiv7424696027 .yiv7424696027replbq {margin:4px;}#yiv7424696027 #yiv7424696027ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv7424696027 #yiv7424696027ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv7424696027 #yiv7424696027ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv7424696027 #yiv7424696027ygrp-mlmsg select, #yiv7424696027 input, #yiv7424696027 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv7424696027 #yiv7424696027ygrp-mlmsg pre, #yiv7424696027 code {font:115% monospace;}#yiv7424696027 #yiv7424696027ygrp-mlmsg * {line-height:1.22em;}#yiv7424696027 #yiv7424696027ygrp-mlmsg #yiv7424696027logo {padding-bottom:10px;}#yiv7424696027 #yiv7424696027ygrp-msg p a {font-family:Verdana;}#yiv7424696027 #yiv7424696027ygrp-msg p#yiv7424696027attach-count span {color:#1E66AE;font-weight:700;}#yiv7424696027 #yiv7424696027ygrp-reco #yiv7424696027reco-head {color:#ff7900;font-weight:700;}#yiv7424696027 #yiv7424696027ygrp-reco {margin-bottom:20px;padding:0px;}#yiv7424696027 #yiv7424696027ygrp-sponsor #yiv7424696027ov li a {font-size:130%;text-decoration:none;}#yiv7424696027 #yiv7424696027ygrp-sponsor #yiv7424696027ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv7424696027 #yiv7424696027ygrp-sponsor #yiv7424696027ov ul {margin:0;padding:0 0 0 8px;}#yiv7424696027 #yiv7424696027ygrp-text {font-family:Georgia;}#yiv7424696027 #yiv7424696027ygrp-text p {margin:0 0 1em 0;}#yiv7424696027 #yiv7424696027ygrp-text tt {font-size:120%;}#yiv7424696027 #yiv7424696027ygrp-vital ul li:last-child {border-right:none !important;}#yiv7424696027

   
Reply | Threaded
Open this post in threaded view
|

Răspuns: [geo-spatial] Vertex number ca atribut

geo-spatial.org mailing list
Salut,

Erorile alea sunt clasice în Python, sunt probleme de indentare (care e esențială în limbajul respectiv). Cel mai probabil clientul de mail nu a știut să păstreze indentarea codului trimis. De aceea e preferabil să folosiți pastebin.com sau alt serviciu asemănător când trimiteți cod. Tentativa mea de a reconstrui codul e la http://pastebin.com/LQJyiTsp , dar e netestată.

Andrei


      De la: "Mihai-Mircea Moise [hidden email] [geo-spatial]" <[hidden email]>
 Către: "[hidden email]" <[hidden email]>
 Trimis: Marţi, 20 Septembrie 2016 9:02:12
 Subiect: Re: [geo-spatial] Vertex number ca atribut
   
    bun, atunci instaleaza-ti team viewer te rog si trimite-mi id-ul si parola taintru eu personal sa vad care-i baiul.

    On Tuesday, September 20, 2016 8:55 AM, "[hidden email] [geo-spatial]" <[hidden email]> wrote:
 

     Salut Mihai,

Multumesc foarte mult pentru ajutor insa nu am reusit sa rulez scriptul fara erori.

Mai jos sunt rezultatele obtinute:
from qgis.core import QgsVectorLayer, QgsField, QgsMapLayerRegistry from PyQt4.QtCore import QVariant from qgis import * from qgis.utils import * def extractPoints( geom ): multi_geom = QgsGeometry()   File "<input>", line 2    multi_geom = QgsGeometry()             ^IndentationError: expected an indented blocktemp_geom = [] if geom.type() == 0: # it's a point if geom.isMultipart():   File "<input>", line 2    if geom.isMultipart():     ^IndentationError: expected an indented blocktemp_geom = geom.asMultiPoint() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'geom' is not definedelse:   File "<input>", line 1    else:       ^SyntaxError: invalid syntaxtemp_geom.append(geom.asPoint()) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'geom' is not definedelif geom.type() == 1: # it's a line   File "<input>", line 1    elif geom.type() == 1: # it's a line       ^SyntaxError: invalid syntaxif geom.isMultipart(): multi_geom = geom.asMultiPolyline() #multi_geog is a multiline   File "<input>", line 2    multi_geom = geom.asMultiPolyline() #multi_geog is a multiline             ^IndentationError: expected an indented blockfor i in multi_geom: #i is a line temp_geom.extend( i )   File "<input>", line 2    temp_geom.extend( i )            ^IndentationError: expected an indented blockelse:   File "<input>", line 1    else:       ^SyntaxError: invalid syntaxtemp_geom = geom.asPolyline() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'geom' is not definedelif geom.type() == 2: # it's a polygon   File "<input>", line 1    elif geom.type() == 2: # it's a polygon       ^SyntaxError: invalid syntaxif geom.isMultipart(): multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon   File "<input>", line 2    multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon             ^IndentationError: expected an indented blockfor i in multi_geom: #i is a polygon for j in i: #j is a line   File "<input>", line 2    for j in i: #j is a line      ^IndentationError: expected an indented blocktemp_geom.extend( j ) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'j' is not definedelse:   File "<input>", line 1    else:       ^SyntaxError: invalid syntaxmulti_geom = geom.asPolygon() #multi_geom is a polygon Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'geom' is not definedfor i in multi_geom: #i is a line temp_geom.extend( i )   File "<input>", line 2    temp_geom.extend( i )            ^IndentationError: expected an indented block# FIXME - if there is none of know geoms (point, line, polygon) show an warning message return temp_geom   File "<input>", line 1SyntaxError: 'return' outside functiondef refresh_layers(): for layer in qgis.utils.iface.mapCanvas().layers():   File "<input>", line 2    for layer in qgis.utils.iface.mapCanvas().layers():      ^IndentationError: expected an indented blocklayer.triggerRepaint() def creare_puncte(): pointLayer = QgsVectorLayer("Point", "puncte", "memory")   File "<input>", line 2    pointLayer = QgsVectorLayer("Point", "puncte", "memory")             ^IndentationError: expected an indented blockpointLayer.startEditing() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'pointLayer' is not definedlayerData = pointLayer.dataProvider() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'pointLayer' is not definedlayerData.addAttributes([ QgsField("ID", QVariant.LongLong)]) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'layerData' is not definedpointLayer.commitChanges() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'pointLayer' is not definedlayer=QgsMapLayerRegistry.instance().mapLayers().values()[0] layer_features=layer.getFeatures() for feature in layer_features: geom=feature.geometry()   File "<input>", line 2    geom=feature.geometry()       ^IndentationError: expected an indented blocki=0 points = extractPoints(geom) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'extractPoints' is not definedfor point in points: feat = QgsFeature(layer.pendingFields())   File "<input>", line 2    feat = QgsFeature(layer.pendingFields())       ^IndentationError: expected an indented blockfeat.setAttribute(0, long(i)) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'feat' is not definedfeat.setGeometry(QgsGeometry.fromPoint(QgsPoint(point))) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'feat' is not defined(res, outFeats) = pointLayer.dataProvider().addFeatures([feat]) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'pointLayer' is not definedi=i+1 print(res,outFeats) Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'res' is not defineddef adaugare_puncte(): _writer = QgsVectorFileWriter.writeAsVectorFormat(pointLayer,r"D:\puncte.shp","utf-8",None,"ESRI Shapefile")   File "<input>", line 2    _writer = QgsVectorFileWriter.writeAsVectorFormat(pointLayer,r"D:\puncte.shp","utf-8",None,"ESRI Shapefile")          ^IndentationError: expected an indented blockiface.addVectorLayer("D:/puncte.shp", "puncte", "ogr") <qgis._core.QgsVectorLayer object at 0x000000001B18B9D8>qgis.utils.iface.activeLayer().setCrs(QgsCoordinateReferenceSystem(3844, QgsCoordinateReferenceSystem.EpsgCrsId)) qgis.utils.iface.activeLayer().setProviderEncoding(u'UTF-8') refresh_layers() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'refresh_layers' is not definedcreare_puncte() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'creare_puncte' is not definedadaugare_puncte() Traceback (most recent call last):  File "<input>", line 1, in <module>NameError: name 'adaugare_puncte' is not defined
 

     #yiv7774237505 #yiv7774237505 -- #yiv7774237505ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv7774237505 #yiv7774237505ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv7774237505 #yiv7774237505ygrp-mkp #yiv7774237505hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv7774237505 #yiv7774237505ygrp-mkp #yiv7774237505ads {margin-bottom:10px;}#yiv7774237505 #yiv7774237505ygrp-mkp .yiv7774237505ad {padding:0 0;}#yiv7774237505 #yiv7774237505ygrp-mkp .yiv7774237505ad p {margin:0;}#yiv7774237505 #yiv7774237505ygrp-mkp .yiv7774237505ad a {color:#0000ff;text-decoration:none;}#yiv7774237505 #yiv7774237505ygrp-sponsor #yiv7774237505ygrp-lc {font-family:Arial;}#yiv7774237505 #yiv7774237505ygrp-sponsor #yiv7774237505ygrp-lc #yiv7774237505hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv7774237505 #yiv7774237505ygrp-sponsor #yiv7774237505ygrp-lc .yiv7774237505ad {margin-bottom:10px;padding:0 0;}#yiv7774237505 #yiv7774237505actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv7774237505 #yiv7774237505activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv7774237505 #yiv7774237505activity span {font-weight:700;}#yiv7774237505 #yiv7774237505activity span:first-child {text-transform:uppercase;}#yiv7774237505 #yiv7774237505activity span a {color:#5085b6;text-decoration:none;}#yiv7774237505 #yiv7774237505activity span span {color:#ff7900;}#yiv7774237505 #yiv7774237505activity span .yiv7774237505underline {text-decoration:underline;}#yiv7774237505 .yiv7774237505attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv7774237505 .yiv7774237505attach div a {text-decoration:none;}#yiv7774237505 .yiv7774237505attach img {border:none;padding-right:5px;}#yiv7774237505 .yiv7774237505attach label {display:block;margin-bottom:5px;}#yiv7774237505 .yiv7774237505attach label a {text-decoration:none;}#yiv7774237505 blockquote {margin:0 0 0 4px;}#yiv7774237505 .yiv7774237505bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv7774237505 .yiv7774237505bold a {text-decoration:none;}#yiv7774237505 dd.yiv7774237505last p a {font-family:Verdana;font-weight:700;}#yiv7774237505 dd.yiv7774237505last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv7774237505 dd.yiv7774237505last p span.yiv7774237505yshortcuts {margin-right:0;}#yiv7774237505 div.yiv7774237505attach-table div div a {text-decoration:none;}#yiv7774237505 div.yiv7774237505attach-table {width:400px;}#yiv7774237505 div.yiv7774237505file-title a, #yiv7774237505 div.yiv7774237505file-title a:active, #yiv7774237505 div.yiv7774237505file-title a:hover, #yiv7774237505 div.yiv7774237505file-title a:visited {text-decoration:none;}#yiv7774237505 div.yiv7774237505photo-title a, #yiv7774237505 div.yiv7774237505photo-title a:active, #yiv7774237505 div.yiv7774237505photo-title a:hover, #yiv7774237505 div.yiv7774237505photo-title a:visited {text-decoration:none;}#yiv7774237505 div#yiv7774237505ygrp-mlmsg #yiv7774237505ygrp-msg p a span.yiv7774237505yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv7774237505 .yiv7774237505green {color:#628c2a;}#yiv7774237505 .yiv7774237505MsoNormal {margin:0 0 0 0;}#yiv7774237505 o {font-size:0;}#yiv7774237505 #yiv7774237505photos div {float:left;width:72px;}#yiv7774237505 #yiv7774237505photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv7774237505 #yiv7774237505photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv7774237505 #yiv7774237505reco-category {font-size:77%;}#yiv7774237505 #yiv7774237505reco-desc {font-size:77%;}#yiv7774237505 .yiv7774237505replbq {margin:4px;}#yiv7774237505 #yiv7774237505ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv7774237505 #yiv7774237505ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv7774237505 #yiv7774237505ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv7774237505 #yiv7774237505ygrp-mlmsg select, #yiv7774237505 input, #yiv7774237505 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv7774237505 #yiv7774237505ygrp-mlmsg pre, #yiv7774237505 code {font:115% monospace;}#yiv7774237505 #yiv7774237505ygrp-mlmsg * {line-height:1.22em;}#yiv7774237505 #yiv7774237505ygrp-mlmsg #yiv7774237505logo {padding-bottom:10px;}#yiv7774237505 #yiv7774237505ygrp-msg p a {font-family:Verdana;}#yiv7774237505 #yiv7774237505ygrp-msg p#yiv7774237505attach-count span {color:#1E66AE;font-weight:700;}#yiv7774237505 #yiv7774237505ygrp-reco #yiv7774237505reco-head {color:#ff7900;font-weight:700;}#yiv7774237505 #yiv7774237505ygrp-reco {margin-bottom:20px;padding:0px;}#yiv7774237505 #yiv7774237505ygrp-sponsor #yiv7774237505ov li a {font-size:130%;text-decoration:none;}#yiv7774237505 #yiv7774237505ygrp-sponsor #yiv7774237505ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv7774237505 #yiv7774237505ygrp-sponsor #yiv7774237505ov ul {margin:0;padding:0 0 0 8px;}#yiv7774237505 #yiv7774237505ygrp-text {font-family:Georgia;}#yiv7774237505 #yiv7774237505ygrp-text p {margin:0 0 1em 0;}#yiv7774237505 #yiv7774237505ygrp-text tt {font-size:120%;}#yiv7774237505 #yiv7774237505ygrp-vital ul li:last-child {border-right:none !important;}#yiv7774237505

   
Reply | Threaded
Open this post in threaded view
|

Re: Răspuns: [geo-spatial] Vertex number ca atribut

geo-spatial.org mailing list
Multumesc Andrei pentru sfat.

As dori sa ii multumesc in mod special lui Mihai Mircea Moise care a fost foarte amabil si m-a ajutat cu acest script.

Felicitari initiatorilor si celor care intretin aceasta comunitate si mult spor in tot ceea ce faceti!!!!

Dupa cum probabil se poate vedea "cuvantarea" nu este punctul meu forte dar concluzia trebuie sa fie urmatoarea: Multumesc si tineti-o tot asa!!!

Adi