jueves, 30 de agosto de 2018

Curso de Programción QGIS3 con Python



Curso de Programación QGIS 3 con Python 


UPM

Publicado el 30 may. 2018
SUSCRIBIRSE 52 MIL
Curso de Programación QGIS 3 con Python por Víctor Olaya (@volayaf) Vídeo producido por el Gabinete de Tele-Educación de la Universidad Politécnica de Madrid





miércoles, 29 de agosto de 2018




Nace el Grupo de usuarios de Qgis España.
En el siguiente enlace se puede acceder a su web.


Grupo de usuarios de Qgis España




jueves, 26 de julio de 2018

CAPAS VISIBLES EN FUNCIÓN DE LA ESCALA

En las propiedades de la capa podemos seleccionar las escalas en que la capa es visible.
Veamos unos ejemplos .


miércoles, 25 de julio de 2018

PROPIEDADES DE MARCADORES , PyQGIS




Teníamos la rejilla de la entrada anterior. Creamos una capa de puntos con el editor. Añadimos las columnas MARKER_ANG  y MARKER_ COL , las rellenamos aleatoriamente, escibimos en la consola Pyton el código de la figura y ejecutamos.                                                                         


REJILLA EXAGONAL


Abrimos la consola pyton y escribimos el código siguiente y ejecutamos.


import numpy as np

bufferLength = 1000
polygonSides = 6

inc_x = 2 * bufferLength * np.cos(np.pi*30/180)
inc_y = inc_x * np.cos(np.pi*30/180)

p1 = QgsPoint(354972.451507, 4473426.04508)

points = []

x = p1.x() + inc_x/2
y = p1.y()

rows = 8
cols = 10
   
for i in range(rows):
    for j in range(cols):
        point = QgsPoint(x, y)
        points.append(point)
        x += inc_x
    y -= inc_y
    ver = i%2

    if ver ==0:
        h = 0
    else:
        h = inc_x/2
    x = p1.x() + h

epsg = 32612

uri = "Polygon?crs=epsg:" + str(epsg) + "&field=id:integer""&index=yes"

mem_layer = QgsVectorLayer(uri,
                           'buffer',
                           'memory')

prov = mem_layer.dataProvider()

for i, point in enumerate(points):
    outFeat = QgsFeature()

    outFeat.setGeometry(QgsGeometry.fromPolygon([[ QgsPoint(point[0] + np.sin(angle)*bufferLength, point[1] + np.cos(angle)*bufferLength)
                        for angle in np.linspace(0, 2*np.pi, polygonSides + 1, endpoint = True) ]]))
   
    outFeat.setAttributes([i])
    prov.addFeatures([outFeat])

QgsMapLayerRegistry.instance().addMapLayer(mem_layer)

martes, 24 de julio de 2018

CREANDO UNA CAPA VECTORIAL CON CÓDIGO PYTON



En QGIS  abrimos la consola de Pyton y escribimos el siguiente código:

#create memory layer
#type, CRS, fields in a uri
mem_layer = QgsVectorLayer("Polygon?crs=epsg:4326&field=id:integer""&field=area:double&index=yes",
                            "Polygon",
                            "memory")
                           
#add Map Layer to Registry
QgsMapLayerRegistry.instance().addMapLayer(mem_layer)

#Prepare mem_layer for editing
mem_layer.startEditing()

#points to add (first and last point must coincide)
points = [[QgsPoint(-150,61),QgsPoint(-151,61), QgsPoint(-151,62),QgsPoint(-150,61)]]

#Set feature
feature = QgsFeature()

#Set geometry
feature.setGeometry(QgsGeometry.fromPolygon(points))

#Area determination (remember: projection is not in meters)
geom = feature.geometry()

area= geom.area()

#set attributes values
feature.setAttributes([1, area])

mem_layer.addFeature(feature, True)

#stop editing and save changes
mem_layer.commitChanges()

Ejecutamos y creamos la capa con un triangulo.