Processing Data For Serving
From OpenAerialMap
OpenAerialMap has the ability to load data from a remote WMS server. The ideal WMS server is one which is fast, and serves data directly in EPSG:4326 (geographic/lat lon unprojected). In order to serve data in this projection, some work must be done on the data provider's side. This page describes, given a set of images and a Linux machine, how to serve your images out as a fast WMS service.
- Download FWTools. http://home.gdal.org/fwtools/FWTools-linux-2.0.0.tar.gz
- Unpack, and run the installer script in the root of the FWTools directory.
- Find a disk with lots of space. If your source data is stored in MrSID or JPEG2000, your resulting uncompressed data will be anywhere from 10-30 times larger.
- Extract and warp your imagery. Something like this will need to be run for each file:
bin_safe/gdalwarp --config GDAL_CACHEMAX 300 -wm 300 -t_srs EPSG:4326 -of GTiff -co TILED=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 /my/input/directory/source_image1.sid /my/output/directory/output_image1.tiff
- If your images are decompressed from a lossy compression format, you will want to run the nearblack utility on them to remove collars:
bin_safe/nearblack -nb 5 /my/output/directory/output_image1.tiff
- Add overviews to the image:
bin_safe/gdaladdo --config GDAL_CACHEMAX 300 /my/output/directory/output_image1.tiff 2 4 8 16 32 64 128 256
- Once you have done this for all the images in the directory, you will want to build a tileindex against the output images:
bin_safe/gdaltindex /my/output/directory/index.shp `find /my/output/directory/ -name \*.tiff`
- Next, you'll want to set up a mapfile for the data:
MAP
EXTENT -180 -90 180 90
IMAGECOLOR 0 0 0
IMAGETYPE jpeg
SIZE 256 256
STATUS ON
UNITS DD
NAME "World"
OUTPUTFORMAT
NAME jpeg
MIMETYPE image/jpeg
DRIVER GD/JPEG
EXTENSION jpeg
TRANSPARENT FALSE
END
PROJECTION
"init=epsg:4326"
END
WEB
IMAGEPATH "/tmp/"
IMAGEURL "/tmp/"
METADATA
"original_projection" "init=epsg:4326"
"original_extents" "-180,-90,180,90"
"wms_srs" "EPSG:4326"
END
END
layer
name "orthos"
type raster
status on
tileindex "/my/output/directory/index.shp"
projection "init=epsg:4326" end
OFFSITE 0 0 0
METADATA
"wms_title" "2006 Massachusetts Orthos"
"wms_abstract" "2006 NAIP photos, releaesd into the public domain. "
"wms_attribution_title" "USDA"
"wms_attribution_onlineresource" "http://www.example.com/my/metadata/link/"
END
END
END
Save this file into /my/output/directory/orthos.map
- Finally, symlink from /usr/lib/cgi-bin/my_orthos to /your/fwtools/home/bin_safe/mapserv (cgi-bin location is specific to your setup -- this part needs more work, need to mention some apache config)
- Lastly, visit http://your.wms.server/cgi-bin/my_orthos?map=/my/output/directory/orthos.map&service=WMS&request=GetCapabilities
