I need to run the following bat file from a MS4W shell which has gdal_retile.py as the final option. I have added C:\ms4w\python\gdal to my pythonpath but within a pyscripter shell I can not import gdal or gdal_retile.py

Without a linux box is there a way to get the final step to work?

CODE of P.bat File

mkdir -p %2\%3
gdal_translate -expand rgba -of GTiff -a_srs EPSG:3857 -co TILED=YES -co BIGTIFF=YES %1 %2\%3\%3_translated.tif
gdalwarp -multi --config GDAL_CACHEMAX 500 -wm 500 -r near -co "COMPRESS=DEFLATE" -co "TILED=YES" -co "BIGTIFF=YES" -srcnodata 255 -dstnodata 255 -overwrite %2\%3\%3_translated.tif %2\%3\%3_rebuilt.tif
mkdir -p %2\%3\pyramids
gdal_retile.py -v -r bilinear -levels 4 -ps 2048 2048 -co "TILED=YES" -co "COMPRESS=DEFLATE" -targetDir %2\pyramids %2\%3\%3_rebuilt.tif


OUTPUT of process

GDAL, mapserv, mapcache, PROJ, and shapelib dll paths set GDAL_DATA path set GDAL_DRIVER_PATH set PROJ_LIB set CURL_CA_BUNDLE set C:\Users\georgec\Desktop>P:\2012\183_TownPlanning_Symbology\Working\Raster_Layer _Creation\4Band_translated_pyramid\p.bat P:\2012\183_TownPlanning_Symbology\Outp ut\8_Bit_TIF_Colourmap_RS\TRC_WC_WaterResource_Catchment\TRC_WC_WaterResourceCat chment.tif P:\2012\183_TownPlanning_Symbology\Working\Raster_Layer_Creation\4Ban d_translated_pyramid wc

C:\Users\georgec\Desktop>mkdir -p P:\2012\183_TownPlanning_Symbology\Working\Ras ter_Layer_Creation\4Band_translated_pyramid\wc

C:\Users\georgec\Desktop>gdal_translate -expand rgba -of GTiff -a_srs EPSG:3857 -co TILED=YES -co BIGTIFF=YES P:\2012\183_TownPlanning_Symbology\Output\8_Bit_TI F_Colourmap_RS\TRC_WC_WaterResource_Catchment\TRC_WC_WaterResourceCatchment.tif P:\2012\183_TownPlanning_Symbology\Working\Raster_Layer_Creation\4Band_translate d_pyramid\wc\wc_translated.tif Input file size is 19844, 26300 0...10...20...30...40...50...60...70...80...90...100 - done.

C:\Users\georgec\Desktop>gdalwarp -multi --config GDAL_CACHEMAX 500 -wm 500 -r n ear -co "COMPRESS=DEFLATE" -co "TILED=YES" -co "BIGTIFF=YES" -srcnodata 255 -dst nodata 255 -overwrite P:\2012\183_TownPlanning_Symbology\Working\Raster_Layer_Cr eation\4Band_translated_pyramid\wc\wc_translated.tif P:\2012\183_TownPlanning_Sy mbology\Working\Raster_Layer_Creation\4Band_translated_pyramid\wc\wc_rebuilt.tif

Creating output file that is 19844P x 26300L. Processing input file P:\2012\183_TownPlanning_Symbology\Working\Raster_Layer_Cr eation\4Band_translated_pyramid\wc\wc_translated.tif. Using band 4 of source image as alpha. Using band 4 of destination image as alpha. 0...10...20...30...40.ERROR 2: Out of memory allocating 130520448 bytes for Unif iedSrcDensity mask. ..50.. C:\Users\georgec\Desktop>mkdir -p P:\2012\183_TownPlanning_Symbology\Working\Ras ter_Layer_Creation\4Band_translated_pyramid\wc\pyramids A subdirectory or file -p already exists. Error occurred while processing: -p.

C:\Users\georgec\Desktop>gdal_retile.py -v -r bilinear -levels 4 -ps 2048 2048 - co "TILED=YES" -co "COMPRESS=DEFLATE" -targetDir P:\2012\183_TownPlanning_Symbol ogy\Working\Raster_Layer_Creation\4Band_translated_pyramid\pyramids P:\2012\183_ TownPlanning_Symbology\Working\Raster_Layer_Creation\4Band_translated_pyramid\wc \wc_rebuilt.tif Traceback (most recent call last): File "C:\ms4w\python\gdal\gdal_retile.py", line 38, in import gdal ImportError: No module named gdal

C:\Users\georgec\Desktop>Pause Press any key to continue . . .

I also get the following Error

ERROR 2: Out of memory allocating 130520448 bytes for Unif iedSrcDensity mask

  • How much memory you got on C:\?
    – Kelso
    Nov 22, 2012 at 3:11
  • 930GB on C and 350gb on D (this is free space off 1TB drives) and they are running 16GB RAM on XEON 3.4GHz. Windows 7, 65-bit.
    – GeorgeC
    Nov 22, 2012 at 4:19
  • What about the P: drive
    – Kelso
    Nov 22, 2012 at 4:40
  • 1.72TB free...these are network drives with plenty of space.
    – GeorgeC
    Nov 22, 2012 at 4:41

1 Answer 1


I tried it in the OSGEO4W shell and gdal_retile.py works fine. However I am getting out of memory errors on larger files in the 2nd stage gdal_warp.

See new question if you want to help! VSIMalloc3() and UnifiedSrcDensity mask errors when running gdal_warp in OSGEO4w shell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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