Solved

Calculate image Height/width to fit the bounding box


Badge +10

Hello there

we are using the staticImageFeatcher transformer in order to get a satellite image that fit the bounding box of vector

the bounding box changes based on each vector's data

is there any way to extract the right value for the  Height/width in the image to set the parameter of the staticMapfetcher dynamic?

 

imageThanks

 

icon

Best answer by virtualcitymatt 1 June 2022, 14:59

View original

3 replies

Userlevel 4
Badge +30

Hi @boubcher

 

Please, could you share your Workspace template?

 

Thanks,

Userlevel 4
Badge +26

I think google maps uses a similar tiling scheme to TMS - For each zoom level each pixel has a (somewhat defined size) - I think if you reproject to Spherical Mercator (EPSG:3857) and then calculate the size of your bounding box you should be able to use the following table to calculate the row and height in number of pixels for a given zoom level

 

https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Resolution_and_Scale

 

for example at level 10 each pixel covers 152.87x152.87 meters (in EPSG:3857) so you can just calculate (xmax-xmin)/152.87 to get the required width.

 

I don't have a google API token so I didn't test it with the transformer but I think that it should work

Badge +10

I think google maps uses a similar tiling scheme to TMS - For each zoom level each pixel has a (somewhat defined size) - I think if you reproject to Spherical Mercator (EPSG:3857) and then calculate the size of your bounding box you should be able to use the following table to calculate the row and height in number of pixels for a given zoom level

 

https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Resolution_and_Scale

 

for example at level 10 each pixel covers 152.87x152.87 meters (in EPSG:3857) so you can just calculate (xmax-xmin)/152.87 to get the required width.

 

I don't have a google API token so I didn't test it with the transformer but I think that it should work

yes, Works,

Thanks to @virtualcitymatt​ 

 

 

image

Reply