read_vector_values

museotoolbox.processing.read_vector_values(vector, *args, **kwargs)[source]

Read values from vector. Will list all fields beginning with the roiprefix ‘band-‘ for example.

Parameters
  • vector (str) – Vector path (‘myFolder/class.shp’,str).

  • *args (str) – Field name containing the field to extract values from (i.e. ‘class’, str).

  • **kwargs (arg) –

    • band_prefix = ‘band-‘ which is the common suffix listing the spectral values (i.e. band_prefix = ‘band-‘).

    • get_features = True, will return features in one list AND spatial Reference.

Returns

  • List values, same length as number of parameters.

  • If band_prefix as parameters, will return one array with n dimension.

See also

museotoolbox.processing.extract_ROI()

extract raster values from vector file.

Examples

>>> from museotoolbox.datasets import load_historical_data
>>> _,vector=load_historical_data()
>>> Y = read_vector_values(vector,'Class')
array([1, 1, 1, 1, 2, 2, 2, 1, 1, 2, 4, 5, 4, 5, 3, 3, 3], dtype=int32)
>>> Y,fid = read_vector_values(vector,'Class','uniquefid')
(array([1, 1, 1, 1, 2, 2, 2, 1, 1, 2, 4, 5, 4, 5, 3, 3, 3], dtype=int32),
 array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17], dtype=int32))