Skip to content

Latest commit

 

History

History
94 lines (74 loc) · 2.52 KB

spatialist.rst

File metadata and controls

94 lines (74 loc) · 2.52 KB

API Documentation

Raster Class

spatialist.raster.Raster

Raster Tools

spatialist.raster

Vector Class

spatialist.vector.Vector

Vector Tools

spatialist.vector

General Spatial Tools

spatialist.auxil

Database Tools

spatialist.sqlite_util

Ancillary Functions

spatialist.ancillary

ENVI HDR file manipulation

spatialist.envi

Data Exploration

spatialist.explorer

Some general examples

in-memory vector object rasterization

Here we create a new raster data set with the same geo-information and extent as a reference data set and burn the geometries from a shapefile into it.
In this example, the shapefile contains an attribute Site_name and one of the geometries in the shapefile has a value of my_testsite for this attribute.
We use the expressions parameter to subset the shapefile and burn a value of 1 in the raster at all locations where the geometry selection overlaps. Multiple expressions can be defined together with multiple burn values.
Also, burn values can be appended to an already existing raster data set. In this case, the rasterization is performed in-memory to further use it for e.g. plotting. Alternatively, an outname can be defined to directly write the result to disk as a GeoTiff.
See spatialist.raster.rasterize for further reference.

>>> from spatialist import Vector, Raster >>> from spatialist.raster import rasterize >>> import matplotlib.pyplot as plt >>> >>> shapefile = 'testsites.shp' >>> rasterfile = 'extent.tif' >>> >>> with Raster(rasterfile) as ras: >>> with Vector(shapefile) as vec: >>> mask = rasterize(vec, reference=ras, burn_values=1, expressions=["Site_Name='my testsite'"]) >>> plt.imshow(mask.matrix()) >>> plt.show()