gemgis.web.load_as_array
gemgis.web.load_as_array#
- gemgis.web.load_as_array(url: str, layer: str, style: str, crs: Union[str, dict], bbox: List[Union[int, float]], size: List[int], filetype: str, transparent: bool = True, save_image: bool = False, path: str = None, overwrite_file: bool = False, create_directory: bool = False) numpy.ndarray #
Loading a portion of a WMS as array
- Parameters
url (str) – Link of the WMS Service, e.g.
url='https://ows.terrestris.de/osm/service?'
layer (str) – Name of layer to be requested, e.g.
layer='OSM-WMS'
style (str) – Name of style of the layer, e.g.
style='default'
crs (str) – String or dict containing the CRS, e.g.
crs='EPSG:4647'
bbox (List[Union[float,int]]) – List of bounding box coordinates, e.g.
bbox=[0, 972, 0, 1069]
size (List[int]) – List of x and y values defining the size of the image, e.g.
size=[1000,1000]
filetype (str) – String of the image type to be downloaded, e.g. ‘filetype=’image/png’``
transparent (bool) – Variable if layer is transparent. Options include:
True
orFalse
, default set toTrue
save_image (bool) – Variable to save image. Options include:
True
orFalse
, default set toFalse
path (str) – Path and file name of the file to be saved, e.g.
path=map.tif
overwrite_file (bool) – Variable to overwrite an already existing file. Options include:
True
orFalse
, default set toFalse
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
- Returns
wms_array – OWSlib map object loaded as np.ndarray
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and WMS Service as array >>> import gemgis as gg >>> wms_map = gg.web.load_as_array(url='https://ows.terrestris.de/osm/service?', layer='OSM-WMS', style='default', crs='EPSG:4647', bbox=[32286000,32328000, 5620000,5648000], size=[4200, 2800], filetype='image/png') >>> wms_map array([[[0.8039216 , 0.7647059 , 0.65882355], [0.85882354, 0.8784314 , 0.6627451 ], [0.87058824, 0.91764706, 0.6666667 ], ..., [0.78431374, 0.7647059 , 0.65882355], [0.8862745 , 0.9019608 , 0.81960785], [0.9529412 , 0.93333334, 0.9019608 ]]], dtype=float32)
See also
load_wms
Load WMS Service
load_as_map
Load Map from WMS Service