You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The objective is that, for a given extent i want to construct a squared, fixed size, image and calculate its real world width. The first part is done thanks to the suggested solution for this.
After downloading the tiles each one is clipped to fit in a previously defined image with a fixed pixel height and width(e.g. 3000 pixel). After that it is drawn with a graphics object to its correct location.
The clipping part was implemented following the exmaple.
Without clipping. when i used all available tiles to construct the image, the real world image width was calculated the following way:
grabbing the top left coordinate of the top left tile
grabbing the top right coordinate of the top right tile
using the haversine formular to calculate the distance between the two coordinates
This was working ok for our use case, since we never had points further apart than 1 kilometer.
Now i am stuck calculating the width of the clipped image.
Initially i tried: realWorldWidth = UnitsPerPixel * imageWidthInPixel
This was way of (and also way wrong).I noticed that the value for UnitesPerPixel is equal for all latitudes.
( By the way: the TileSource is using a standard WebMercator projection and has 0.0746455 UnitsPerPixel at Zoomlevel 21.)
I read that the WebMercator projection distorts distances as you move away from the equator.
To take this into account i found a scaling factor of cosh(latitude) to get:
realWorldWidth = UnitsPerPixel * imageWidthInPixel * cosh(latitude)
Which is better but still wrong.
I could use the Haversine-approach, calculated it on the not-clipped version, break it down for a single pixel and then multiply it by the resulting
image size. This feels utterly complex.
Is there a clean and correct way to calculate the width of a cropped image?
The text was updated successfully, but these errors were encountered:
TimThaler
changed the title
Calculated read world image width of clipped image
Calculate real world width of a clipped image
Feb 9, 2024
The objective is that, for a given extent i want to construct a squared, fixed size, image and calculate its real world width. The first part is done thanks to the suggested solution for this.
After downloading the tiles each one is clipped to fit in a previously defined image with a fixed pixel height and width(e.g. 3000 pixel). After that it is drawn with a graphics object to its correct location.
The clipping part was implemented following the exmaple.
Without clipping. when i used all available tiles to construct the image, the real world image width was calculated the following way:
This was working ok for our use case, since we never had points further apart than 1 kilometer.
Now i am stuck calculating the width of the clipped image.
Initially i tried:
realWorldWidth = UnitsPerPixel * imageWidthInPixel
This was way of (and also way wrong).I noticed that the value for UnitesPerPixel is equal for all latitudes.
( By the way: the TileSource is using a standard WebMercator projection and has 0.0746455 UnitsPerPixel at Zoomlevel 21.)
I read that the WebMercator projection distorts distances as you move away from the equator.
To take this into account i found a scaling factor of
cosh(latitude)
to get:realWorldWidth = UnitsPerPixel * imageWidthInPixel * cosh(latitude)
Which is better but still wrong.
I could use the Haversine-approach, calculated it on the not-clipped version, break it down for a single pixel and then multiply it by the resulting
image size. This feels utterly complex.
Is there a clean and correct way to calculate the width of a cropped image?
The text was updated successfully, but these errors were encountered: