Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Page Properties
hiddentrue
idKB


ThemeMapping
Type

Raster

Available from


Overview

The following scripts convert images into suitable geotiffs for fast map serving without losing clarity. Completely based upon Paul Ramsey's Geotiff for Dummies guide.

...

Code Block
languagebash
cd <folder>
dir /s/b *.tif > optfile.txt
gdaltindex tileindex.shp --optfile optfile.txt

If you have multiple folders to process you can create a batch file that takes in a input file containing a list of directories

Paste code macro
@echo off
FOR /F "usebackq tokens=*" %%x in (input.txt) DO (
	echo processing: %%x	
	cd "%%x"
	del optfile.txt >nul 2>&1
	FOR /F "delims=" %%G IN ('dir /s /b *.tif') DO (
		echo "%%G">>optfile.txt
	)
	gdaltindex.exe tileindex.shp --optfile optfile.txt
)

With an input.txt such as:

Paste code macro
E:\iShareData\Data\Raster_folder_1
E:\iShareData\Data\Raster_folder_2


Create a .map file.

Code Block
MAP
	EXTENT 0 0 700000 1300000
	INCLUDE "_common.map"
	UNITS METERS
	TEMPLATEPATTERN '.'
 	IMAGECOLOR 238 238 237
	IMAGETYPE AGG_Q
	RESOLUTION 72
	SHAPEPATH "../../"
	SIZE 512 512
	MAXSIZE 8192
	STATUS ON
	CONFIG  "MS_ERRORFILE" "D:/mapserver/tmp/logs/base_rasters_debug.log"
	NAME "Raster_WMS"
	PROJECTION
		 "init=epsg:27700"
	END
	DEBUG 0
	IMAGETYPE png
	OUTPUTFORMAT
		NAME "png"
		MIMETYPE "image/png"
		DRIVER "AGG/PNG"
		EXTENSION "png"
		IMAGEMODE "RGBA" #CHANGED
		TRANSPARENT TRUE
		FORMATOPTION "TRANSPARENT=ON"
	END

	OUTPUTFORMAT
		NAME "AGG_JPEG"
		MIMETYPE "image/jpeg"
		DRIVER "AGG/JPEG"
		EXTENSION "JPG"
		IMAGEMODE "RGB"
		FORMATOPTION "interlace=off"
	END

	LEGEND
		IMAGECOLOR 255 255 255
		KEYSIZE 20 10
		KEYSPACING 5 5
		LABEL
			SIZE small
			TYPE bitmap
			BUFFER 0
			COLOR 0 0 0
			FORCE FALSE
			MINDISTANCE -1
			MINFEATURESIZE -1
			OFFSET 0 0
			PARTIALS TRUE
			MAXLENGTH 25
			WRAP " "
		END
		POSITION LL
		STATUS OFF
	END

	QUERYMAP
		COLOR 255 255 0
		SIZE -1 -1
		STATUS OFF
		STYLE HILITE
	END
	
	SCALEBAR
		COLOR 0 0 0
		IMAGECOLOR 255 255 255
		INTERVALS 4
		LABEL
			SIZE MEDIUM
			TYPE BITMAP
			BUFFER 0
			COLOR 0 0 0
			FORCE FALSE
			MINDISTANCE -1
			MINFEATURESIZE -1
			OFFSET 0 0
			PARTIALS TRUE
		END
		POSITION LL
		SIZE 200 3
		STATUS OFF
		STYLE 0
		UNITS MILES
	END
	
	WEB
		IMAGEPATH "D:\mapserver\tmp\\"
		IMAGEURL ""
		TEMPLATE "globexml.xml"
		METADATA
			 ows_title "Rasters"
			 ows_srs "EPSG:27700"
			 ows_abstract "WMS Rasters"
			 ows_enable_request "*"
		END
	END
	
    LAYER
        NAME "Aerial"
        TYPE RASTER
        STATUS OFF
        METADATA
			"ows_title"			  "Aerial Imagery"
			"ows_abstract"		  "Aerial Imagery"
        END
        TILEINDEX "<folder>\tileindex.shp"
    END

END

...