Thursday, 29 August 2019

geoserver - gdal.py as part of bat script in windows 7


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

Pause

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





Answer



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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...