OS Python week 3: Filters & analysis; Functions & …
Filters & Simple Analysis of
Vector Data; Functions &
Modules
Open Source RS/GIS Python
Week 3
OS Python week 3: Filters & analysis; Functions & modules [1]
Attribute filters
? The Layer object has a method
SetAttributeFilter()
? Resets reading so GetNextFeature()
gets the first feature that matches the filter
? Pass None to clear the filter
>>>
42
>>>
>>>
6
>>>
>>>
42
layer.GetFeatureCount()
layer.SetAttributeFilter("cover = 'shrubs'")
layer.GetFeatureCount()
layer.SetAttributeFilter(None)
layer.GetFeatureCount()
OS Python week 3: Filters & analysis; Functions & modules [2]
Spatial filters
? There are two methods on the Layer
object to set spatial filters
? SetSpatialFilter()
? SetSpatialFilterRect(, ,
, )
? Use SetSpatialFilter(None) to clear the
filter
OS Python week 3: Filters & analysis; Functions & modules [3]
layerAreas is polygon and layerSites is points
>>> featAreas = layerAreas.GetNextFeature()
>>> poly = featAreas.GetGeometryRef()
>>> layerSites.GetFeatureCount()
42
>>> layerSites.SetSpatialFilter(poly)
>>> layerSites.GetFeatureCount()
3
>>> layerSites.SetSpatialFilterRect(460000,
4590000, 490000, 4600000)
>>> layerSites.GetFeatureCount()
4
>>> layerSites.SetSpatialFilter(None)
>>> layerSites.GetFeatureCount()
42
OS Python week 3: Filters & analysis; Functions & modules [4]
More complicated filters
? DataSource objects have a method
ExecuteSQL()
? Returns a Layer object that can be looped
through like other layers
? When done with the resulting layer, call
ReleaseResultSet() on
the DataSource
? See
for more info about valid SQL syntax
OS Python week 3: Filters & analysis; Functions & modules [5]
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- python os vs subprocess
- python os system command
- python os path join
- python os path join glob
- python os mkdir recursive
- python 3 functions list
- python 3 functions pdf
- python download 3 8 6
- espn nfl week 3 predictions
- anaconda python version 3 6 download
- 3 09 exponential functions practice test
- math functions python 3 8