Skip to main content
Solved

Calculate image Height/width to fit the bounding box


boubcher
Contributor
Forum|alt.badge.img+11

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

 

Best answer by virtualcitymatt

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

View original
Did this help you find an answer to your question?

3 replies

danilo_fme
Evangelist
Forum|alt.badge.img+41
  • Evangelist
  • May 31, 2022

Hi @boubcher

 

Please, could you share your Workspace template?

 

Thanks,


virtualcitymatt
Celebrity
Forum|alt.badge.img+34

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


boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • June 3, 2022
virtualcitymatt wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings