QGIS Python Console

Some quick pointers for using the Python console in QGIS.

1) create reference to a shapefile and open it using OGR

layer = QgsVectorLayer("path\\to\\file.shp", "layer_name_you_like", "ogr")
if not layer.isValid():
 print "FAIL"

2) Render the layer


3) Interrogate the layer

layer = qgis.utils.iface.activeLayer()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A WordPress.com Website.

Up ↑

%d bloggers like this: