I want to download the entire tiff of the city London. Since there is a limit size of Bbox, so I split the shape to 9 sub-bbox, and use wms request approach to download all of them.
The problem is that the tiffs I download are not so good as I expected.
you can see that there are gaps and white boarders around some tiffs.
Here is my scripts:
london = gpd.read_file(shpPath)
london_crs = CRS.UTM_30N
london = london.to_crs(crs={‘init’: CRS.ogc_string(london_crs)})
london_shape = london.geometry.values.tolist()[-1]
bbox_splitter = BBoxSplitter([london_shape], london_crs, (3, 3))
bbox_list = np.array(bbox_splitter.get_bbox_list())
wms_true_color_request =
WmsRequest(data_folder=‘/Users/guoqiushi/Documents/test_dir_tiff’,
layer=‘TRUE-COLOR-S2-L1C’,
bbox=bbox_list[8],
time=‘latest’,
width=512, height=856,
image_format=MimeType.TIFF,
instance_id=INSTANCE_ID)
wms_true_color_request.save_data()
colud anyone help me to find out where bugs are?
1 Like
Hello!
To help you debug we would need the shapefile you are using. What spatial resolution would you like to retrieve?
If for example you wanted pixels with a spatial resolution of 60metres, you could use WCS requests:
london = gpd.read_file(shpPath)
london_crs = CRS.UTM_30N
london = london.to_crs(crs={‘init’: CRS.ogc_string(london_crs)})
london_shape = london.geometry.values.tolist()[-1]
bbox_splitter = BBoxSplitter([london_shape], london_crs, (3, 3))
bbox_list = bbox_splitter.get_bbox_list()
wcs_true_color_request = WcsRequest(data_folder=’/Users/guoqiushi/Documents/test_dir_tiff’, layer=‘TRUE-COLOR-S2-L1C’,
bbox=bbox_list[8],
time=‘latest’,
resx='60m', resy='60m',
image_format=MimeType.TIFF,
instance_id=INSTANCE_ID)
wcs_true_color_request.save_data()
The service can return images with maximum size 5000x5000 pixels, so you need to be careful not to request images larger than that.
Hello, Devis!
Thanks for your reply! I follow your advice and used wcs_request to download the tif. To guarantee the bbox size not exceed the 50000 pixel, I split the shape into 100 sub-bbox.
But there are still bugs:
It would be nice if you could debug it to find what’s the reason of it.
shapefile
This is the shape file of london, in the folder qg_shapefile.
I cannot access the shapefile, perhaps you did not make the folder public on the store.