Raster
Bases: Spatial
Represents a binary mask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Dict[str, Union[ndarray, str, None]]
|
An raster value. |
required |
Attributes:
Name | Type | Description |
---|---|---|
area |
Float
|
|
array |
ndarray
|
|
geometry |
Union[Box, Polygon, MultiPolygon]
|
|
height |
int
|
|
width |
int
|
|
Raises:
Type | Description |
---|---|
TypeError
|
If |
Examples:
Generate a random mask.
>>> import numpy.random
>>> height = 640
>>> width = 480
>>> array = numpy.random.rand(height, width)
Convert to binary mask.
Create Raster.
Source code in valor/schemas/symbolic/types.py
1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 |
|
Attributes
valor.schemas.Raster.area: Float
property
Symbolic representation of area.
valor.schemas.Raster.array: np.ndarray
property
The bitmask as a numpy array.
Returns:
Type | Description |
---|---|
Optional[ndarray]
|
A 2D binary array representing the mask if it exists. |
valor.schemas.Raster.geometry: typing.Union[Box, Polygon, MultiPolygon]
property
The geometric mask if it exists.
Returns:
Type | Description |
---|---|
Box | Polygon | MultiPolygon | None
|
The geometry if it exists. |
valor.schemas.Raster.height: int
property
Returns the height of the raster if it exists.
valor.schemas.Raster.width: int
property
Returns the width of the raster if it exists.
Functions
valor.schemas.Raster.__init__(value)
Initialize and instance of a raster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Dict[str, Union[ndarray, Box, Polygon, MultiPolygon, None]]
|
The raster in dictionary format {"mask": |
required |
Source code in valor/schemas/symbolic/types.py
valor.schemas.Raster.__validate__(value)
classmethod
Validates typing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Any
|
The value to validate. |
required |
Raises:
Type | Description |
---|---|
TypeError
|
If the value type is not supported. |
Source code in valor/schemas/symbolic/types.py
valor.schemas.Raster.decode_value(value)
classmethod
Decode object from JSON compatible dictionary.
Source code in valor/schemas/symbolic/types.py
valor.schemas.Raster.encode_value()
Encode object to JSON compatible dictionary.
Source code in valor/schemas/symbolic/types.py
valor.schemas.Raster.from_geometry(geometry, height, width)
classmethod
Create a Raster object from a geometric mask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry
|
Union[Box, Polygon, MultiPolygon]
|
Defines the bitmask as a geometry. Overrides any existing mask. |
required |
height
|
int
|
The intended height of the binary mask. |
required |
width
|
int
|
The intended width of the binary mask. |
required |
Returns:
Type | Description |
---|---|
Raster
|
|
Source code in valor/schemas/symbolic/types.py
valor.schemas.Raster.from_numpy(mask)
classmethod
Create a Raster object from a NumPy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask
|
ndarray
|
The 2D binary array representing the mask. |
required |
Returns:
Type | Description |
---|---|
Raster
|
|
Raises:
Type | Description |
---|---|
ValueError
|
If the input array is not 2D or not of dtype bool. |