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()
Tagged , ,

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: