vectorreader

This module contains the Vector and VectorReader class that perform on-the-fly rasterization of vectors into raster blocks to fit in with ImageReader and ImageWriter classes.

class rios.vectorreader.Vector(filename, inputlayer=0, burnvalue=1, attribute=None, filter=None, alltouched=False, datatype=<Mock name='mock.uint8' id='139767081504912'>, tempdir='.', driver='HFA', driveroptions=['COMPRESSED=TRUE', 'IGNOREUTM=TRUE'], nullval=0)[source]

Class that holds information about a vector dataset and how it should be rasterized. Used for passing to VectorReader.

cleanup()[source]

Remove temporary file(s) and close dataset

matchingProj(proj)[source]

Returns True if the current vector has the same projection as the given projection. The projectino can be given as either a WKT string, or an osr.SpatialReference instance.

reproject(proj)[source]

Reproject the current vector to the given projection. Places the result in a temporary shapefile, and opens it. Returns the ogr.Layer object resulting.

Assumes that shapefile format will always be sufficient - I can’t think of any reason why not.

This reprojection becomes a part of the “state” of the current object, i.e. there can only be one “reprojected” copy of the current vector. This should be fine.

class rios.vectorreader.VectorReader(vectorContainer, progress=None)[source]

Class that performs rasterization of Vector objects.

close()[source]

Closes all datasets and removes temporary files.

rasterize(info)[source]

Rasterize the container of Vector objects passed to the constuctor. Returns blocks in the same form as the container passed to the constructor.

static rasterizeSingle(info, vector, progress)[source]

Static method to rasterize a single Vector for the extents specified in the info object.

For efficiency, it rasterizes the whole working grid, and caches this, and then reads the relevant section of the gridd for the current block.

Will reproject the vector into the working projection, if required.

A single numpy array is returned of rasterized data.

rios.vectorreader.rasterizeProgressFunc(value, string, progressObj)[source]

called by gdal.RasterizeLayer