Solved

How to set reference system for {x},{y},{z} PNG raster images


I have a set of PNG images downloaded from a service like:

 

http://tile.openstreetmap.org/{z}/{x}/{y}.png

 

The images are named:

 

09_118_180.PNG

 

09_119_180.PNG

 

etc.

How can I combine these image in FME and project them correctly?

icon

Best answer by jdh 31 May 2019, 15:54

View original

3 replies

Badge +22

OSM uses a slippy map.

 

 

To go from tile numbers to lat long use the following equations:
n = 2 ^ zoom lon_deg = xtile / n * 360.0 - 180.0 
lat_rad = arctan(sinh(π * (1 - 2 * ytile / n))) 
lat_deg = lat_rad * 180.0 / π

This returns the NW corner of the image. You can use xtile+0.5 and ytile+0.5 to get the center of the tile

Badge +22

OSM uses a slippy map.

 

 

To go from tile numbers to lat long use the following equations:
n = 2 ^ zoom lon_deg = xtile / n * 360.0 - 180.0 
lat_rad = arctan(sinh(π * (1 - 2 * ytile / n))) 
lat_deg = lat_rad * 180.0 / π

This returns the NW corner of the image. You can use xtile+0.5 and ytile+0.5 to get the center of the tile

Personally I would calculate all four corners and use the RasterGeoreferencer  and then the RasterMosaicker, then use a CoordinateSystemSetter to define the projection as EPSG 3857.

OSM uses a slippy map.

 

 

To go from tile numbers to lat long use the following equations:
n = 2 ^ zoom lon_deg = xtile / n * 360.0 - 180.0 
lat_rad = arctan(sinh(π * (1 - 2 * ytile / n))) 
lat_deg = lat_rad * 180.0 / π

This returns the NW corner of the image. You can use xtile+0.5 and ytile+0.5 to get the center of the tile

Works like a charm, thank you!

 

I ended up not using the RasterMosaicker as it opened too many files which would require to use the Mosaicker in two steps. Instead I vectorized each raster individually and combined the results at the end, which probably also is faster for my scenario.

0684Q00000ArMR9QAN.png

Reply