Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8596509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:41:48+00:00 2026-06-12T00:41:48+00:00

I use gdal_retile.py script to cut rasters into tiles (rewritten to C# ). Everything

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:41:49+00:00Added an answer on June 12, 2026 at 12:41 am

    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, 432 and 433 – if u want to revert my changes into original, just replace _scaleFactor variable by 2 and remove all the _scaleFactor calculations): http://pastebin.com/0qUCVk9J

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

use C#,want to upload excel file on google doc. bellow syntax use to upload
I want to introduce a variable [i] into a string in Python. For example
Use to work with a MySQL + + (library for C + +) The
I try to rewrite pct2rgb.py script into C# (this script gets 8-bit TIFF image
use case is simple: I want to run some boiler plate code before each
Use case is this: I want to unit test (in browser, QUnit or something
use a reapeter to display data, but sometimes the data is to big to
USE [Fk_Test2] GO /****** Object: Table [dbo].[Owners] Script Date: 08/20/2010 16:52:44 ******/ SET ANSI_NULLS
Use of rails 3 recaptcha. In view _form.html.erb insert <%= recaptcha_tags %> But when
USE AdventureWorks2008R2; GO INSERT INTO myTestSkipField SELECT * FROM OPENROWSET(BULK 'C:\myTestSkipField-c.dat', FORMATFILE='C:\myTestSkipField.fmt' ) AS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.