Can I read a raster map which has been constructed in mapserver as WMS with rasterio?
I tried :
from rasterio.io import MemoryFile
def print_metadata(dataset):
print(dataset.profile)
url ='http://localhost:8080/?map=/maps/ivm3.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=tr_ivm_gray&STYLES=&SRS=epsg:3857&BBOX=2857613.741389,4274927.875099,4989229.633477,5176940.449967&WIDTH=1160&HEIGHT=540&FORMAT=image/tiff'
tif_bytes = open(url,'rb').read()
with MemoryFile(tif_bytes) as memfile:
with memfile.open() as dataset:
print_metadata(dataset)
and it gives :
FileNotFoundError: [Errno 2] No such file or directory: 'http://localhost:8080/?map=/maps/ivm3.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=tr_ivm_gray&STYLES=&SRS=epsg:3857&BBOX=2857613.741389,4274927.875099,4989229.633477,5176940.449967&WIDTH=1160&HEIGHT=540&FORMAT=image/tiff'
another code :
raster=rasterio.open(url)
print (type(raster))
print ( raster.meta )
print ( raster.count )
array=raster.read()
this gives:
<class 'rasterio.io.DatasetReader'>
{'driver': 'WMS', 'dtype': 'uint8', 'nodata': None, 'width': 1073741824, 'height': 454363579, 'count': 3, 'crs': CRS({'init': 'epsg:3857'}), 'transform': Affine(0.001985222000710666, 0.0, 2857613.741389,
0.0, -0.0019852220040462356, 5176940.449967)}
3
Traceback (most recent call last):
File "rio1.py", line 20, in <module>
array=raster.read()
File "rasterio/_io.pyx", line 322, in rasterio._io.DatasetReaderBase.read
MemoryError
raster.read() tries to read too much data. What can I do here?
'width': 1073741824, 'height': 454363579
you're trying to read way too much data.