Skip to content

Vector functions

mcvittal edited this page Dec 20, 2016 · 17 revisions

This page contains a listing of all the vector functions currently supported in Qpy.

vector_basic class

This class contains all the basic geoprocessing functions found within QGIS.

clip

A function to clip a polygon feature to the extent of another polygon feature.
Source: modules/vector.py Class: VectorA

Example:

import qpy
qpy.vector_basic.clip("polygon_to_be_clipped.shp", "extent_polygon.shp", "output_polygon.shp")

erase

A reverse of the clip function. Erases overlaying polygon features from an input polygon.
Source: modules/vector.py Class: VectorA

Example:

import qpy
qpy.vector_basic.erase("erased.shp", "cutter.shp", "output_polygon.shp")

intersect

Calculates the geometric intersection of two shapefiles.
Source: modules/vector.py Class: VectorA

Example:

qpy.vector_basic.intersect("shape1.shp", "shape2.shp", "output_shape.shp")

merge

Merges two shapefiles together. Can be points, lines, or polygons, but must all be the same type.
Source: modules/vector.py Class: VectorA

Example:

qpy.vector_basic.merge("shape1.shp", "shape2.shp", "output_shape.shp")

To merge more than two shapefiles, use the merge_multiple or merge_folder method.

merge_multiple

Merges a list of shapefiles together. Uses the merge method, so must all be the same data type.
Source: modules/vector.py Class: VectorA

Example:

qpy.vector_basic.merge_multiple(["shape1.shp", "shape2.shp", "shape3.shp", "shape4.shp", "shape5.shp"], "output_shape.shp")

merge_folder

Merges a folder of shapefiles.
Source: modules/vector.py Class: VectorA

Example:

qpy.vector_basic.merge_folder("/home/mcvittal/gis/tobemerged", "output_shape.shp")

select

Extracts features from a shapefile based on SQL table selection.
NOTE: ogr2ogr is not working in my test environment on Windows, but it works on my Linux test environment. YMMV.

Example:

qpy.vector_basic.select("roads.shp", "ferguson_road.shp", "ROADNAM LIKE 'Ferguson%'")

Clone this wiki locally