mapgrab image

Mapgrab

Contents:

Downloads

About Mapgrab

What is Mapgrab?

Mapgrab is command-line tool to get a high resolution georeferenced raster map from a wms map server.

What is it good for?

Possible uses:
  1. To get a georeferenced background map raster layer of an area of interest for off-line use in a desktop GIS application. *
  2. To get a map image with resolution suitable for printing. *
  3. With your own, local map server (like free UMN Mapserver) and GIS data, you can use it even to
    1. Make cut-outs of your existing large raster datasets
    2. Make format, resolution and datum conversions of such cut-outs
    3. Convert portions of your vector layers to raster layers.
    4. Create a composition of several raster and vector layers and save it as single raster layer.
* Legal note: Please be aware of possible legal restrictions when using data created from public map servers!

Usage

You need to know URL of the wms request to get low-resolution image of given map extent with needed map layer(s). The simplest way to get it is to simply open the needed map in a wms web interface (either in the map server's own web interface, or in a www client - and you can even install one yourself to your computer), zoom to the desired location, right-click the map image and choose to open the image alone. Then you can copy and paste the map url from the adress bar of your browser.  If this is not possible, you need to understand the wms server url parameters and possibly also understand the wms GetCapabilities request XML result to create the url yourself.
Then you can use the script to get the image like this:

mapgrab "mapurl" [[-f factor] | [-p size]] [-r rows] [-c cols] [-t] [-o outfile]

-o, --output Output file name.
[string, default: map.png]
-f, --enlarge-factor Enlarge the map image from original url by factor.
[decimal, default: 2]
-p, --pixel-size Width of output image pixel in map units.
[decimal, default: undefined]
-r, --rows Number of rows to divide map to for downloading.
[integer, default: 2]
-c, --cols Number of columns to divide map to for downloading.
[integer, default: 2]
-t, --test Test run. Do not download anything, just compute and
print number and dimensions of seams to download and
output image dimensions and resolution with actual
settings.
-n, --no-log Do not generate a log file.
-h, --help Show this help screen.
-v, --version Version info.

The map is downloaded in tiles, then stitched to the resulting image. The -r and -c parameters set the number of tiles, while the -f factor or -r pixel resolution sets the size of resulting image.
Possible output file formats are .tif, .jpg and .png, the format is chosen by the suffix used.

Example: You need at least 1200x1200 pixel image of given area, but the map server only serves images up to 500x500 px and the web interface produces 400x400 px images.

Zoom to the desired map extent in the web interface and get the url as described above. As you have url for 400x400 px image and you need 1200x1200,  the enlarge factor is 3. You need at least 3 rows and 3 columns to get under the 500x500 px limit of the server for the tiles. The commad line would look like this:

mapgrab "<URL of the map>" -f 3 -r 3 -c 3 -o mymap.tif
You can use also .png or .jpg image as output. In all cases you should get map of the area in the format and resolution you specified with world-file. Of course, the georeferenced image you get is in the projection and datum served by the wms map server, but with most servers you can choose from several posibilities by epsg code in the url. See documentation for OGC WMS map server's cgi interface, for example in documentation for UMN mapserver.

License

Mapgrab is free software licensed under the General Public License. See details in file LICENSE in the download package, or see http://www.gnu.org/copyleft/gpl.html

Development plan

0.3-1.0 release plan:
Long-time plan:
Cooperation:
Everyone is welcome to send bug reports, improvement recommendations or even customized code to my e-mail tomas.brunclik(at)upce.cz.

Document made with Nvu