Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Is there a way to define custom tile names during a gdal_retile.py process, other than the default _01_01. For instance, suppose I want to start naming my tiles at 100_100, is this possible?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

@algone, if you're comfortable editing the utility's gdal_retile.py Python file, open it, and find where the getTileName() method is defined.

In my version, it appears at line #652 and looks like this:

def getTileName(minfo,ti,xIndex,yIndex,level = -1):

To accommodate what you're wanting to do, I can merely override the xIndex and yIndex values as follows (I'm showing only a portion of that method for some context, note the "ADD THIS" comments):

def getTileName(minfo,ti,xIndex,yIndex,level = -1):
    """
    creates the tile file name
    """
    global LastRowIndx

    xIndex += 100    # ADD THIS, where 100 is your preferred starting value
    yIndex += 100    # AND THIS, ditto

    max = ti.countTilesX
    if (ti.countTilesY > max):
        max=ti.countTilesY
    countDigits= len(str(max))
    # ..
    # .. shortened for brevity
    # ..

I tested it, and it did what you're wanting, basically calling the utility like this:

gdal_retile.py "D:\GIS\LongPathToData\jasper_nw.tif" -v -of png -ps 512 512 -r cubic -tileIndex test -levels 8 -targetDir "D:\GIS\LongPathToData\test2" -useDirForEachRow

share|improve this answer
1  
Thanks a heap! that worked like charm. I only changed it abit to enable user to define additional startRowNum and startColNum parameters –  algone Oct 7 '13 at 15:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.