Skip to main content
Solved

Calculate image Height/width to fit the bounding box

  • May 31, 2022
  • 3 replies
  • 180 views

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • May 31, 2022

Hi @boubcher

 

Please, could you share your Workspace template?

 

Thanks,


virtualcitymatt
Celebrity
Forum|alt.badge.img+47
  • Celebrity
  • 2000 replies
  • Best Answer
  • June 1, 2022

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
  • 212 replies
  • June 3, 2022

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