Graphics Reference
In-Depth Information
for feature in provider.getFeatures(QgsFeatureRequest()):
index.insertFeature(feature)
Don't forget that you can use the Qg-
sFeatureRequest.setFilterExpression() method to limit the set of features
that get added to the index.
Once you have the spatial index, you can use it to perform queries based on the position
of the features. In particular:
• You can find one or more features that are closest to a given point using the
nearestNeighbor() method. For example:
features = index.nearestNeighbor(QgsPoint(long, lat),
5)
Note that this method takes two parameters: the desired point as a QgsPoint
object and the number of features to return.
• You can find all features that intersect with a given rectangular area by using the
intersects() method, as follows:
features = index.intersects(QgsRectangle(left, bottom,
right, top))
Raster layers
Raster-format geospatial data is essentially a bitmapped image, where each pixel or "cell"
in the image corresponds to a particular part of the Earth's surface. Raster data is often or-
ganized into bands , where each band represents a different piece of information. A com-
mon use for bands is to store the red, green, and blue component of the pixel's color in a
separate band. Bands might also represent other types of information, such as moisture
level, elevation, or soil type.
There are many ways in which raster information can be displayed. For example:
• If the raster data only has one band, the pixel value can be used as an index into a
palette . The palette maps each pixel value maps to a particular color.
• If the raster data has only one band but no palette is provided, the pixel values can
be used directly as a grayscale value; that is, larger numbers are lighter and smal-
ler numbers are darker. Alternatively, the pixel values can be passed through a
pseudocolor algorithm to calculate the color to be displayed.
Search WWH ::




Custom Search