I use gdal_retile.py script to cut rasters into tiles (rewritten to C#). Everything works fine, but I want my script to work in a little different way. What I want is to change the first level scale. I want it to be calculated using the pattern:
private const double MetersPerInch = 0.0254;
private const double DPI = 96;
private double GetScale(int meters, int pixels)
{
return meters/pixels/MetersPerInch*DPI;
}
For example.
If I get a raster of size 4k x 4k px and it’s 100 km, then:
scale = 100000 / 4000 / 0.0254 * 96 = ~94488
Now I need to find the first scale higher than counted that is a power of 2. In this case it’s 1:131072. And I should set it as my scale for the first level. Next levels’ scale should be a power of 2: [1:262144, 1:524288, 1:1048576, ...].
Could any1 help me to modify the script? I don’t care about the language (it can be done in Python or C#).
Thanks in advance for any solutions!
Ok, I did it!
Here’s the source code (maybe some1 will need it in the future – be careful, cuz I did my changes in lines
370,432and433– if u want to revert my changes into original, just replace_scaleFactorvariable by2and remove all the_scaleFactorcalculations): http://pastebin.com/0qUCVk9J