Hi Viewers,
From this video, you will come to know how to use python(Python Interface) in QGIS. For better understanding, follow below program:
Python Interface
iface
help(iface)
##Add Vector layer:
iface.addVectorLayer("d:/.../points.shp","points", "ogr")
##Zoom
iface.zoomFull()
iface.zoomToPrevious()
iface.zoomToNext()
##Active Layer
layer = iface.activeLayer()
##Attribute Table
iface.showAttributeTable(layer)
##Layer Properties
iface.showLayerProperties(layer)
##New Project
iface.newProject()
##Add New Layer
help(iface.addVectorLayer)
iface.addVectorLayer("d:/.../points.shp","points", "ogr")
layer = iface.activeLayer()
dir(layer)
##Feature details (Attributes)
for f in layer.getFeatures():
print (f)
run python
..............................
for f in layer.getFeatures():
print(f['place'], f['amenity'])
run python
....................
##Coordinates (Lat, Long)
for f in layer.getFeatures():
geom = f.geometry()
print (geom.asPoint())
run python
..............
for f in layer.getFeatures():
geom = f.geometry()
print (geom.asPoint().x())
runpython
.............................
for f in layer.getFeatures():
geom = f.geometry()
print(geom.asPoint().y(), geom.asPoint().x()) (Lat (y)/Long(x))
run python
................................
##Coordinates along with Other Fields
for f in layer.getFeatures():
geom = f.geometry()
print ('%s, %s, %f, %f' % (f['place'], f['amenity'], geom.asPoint().y(), geom.asPoint().x()))
run python
.............................
On this page of the site you can watch the video online QGIS using Python Programming for Beginners with a duration of hours minute second in good quality, which was uploaded by the user MSR Geo Spatial Solutions 19 September 2020, share the link with friends and acquaintances, this video has already been watched 46,240 times on youtube and it was liked by 445 viewers. Enjoy your viewing!