Link to TerraServer Using HTML

This page describes how to include TerraServer imagery or topographical map images on your web page. All USGS imagery on TerraServer is public domain data. Thus you can include TerraServer tiles on your own web pages! We do ask that you give visible credit to the US Geological Survey.

On your web page, create an <img src> tag that references the TerraServer image tile you wish to include on your web page. The TerraServer script file, http://terraserver-usa.com/tile.ashx, returns either a Jpeg or GIF image. All tiles returned are 200 pixels wide by 200 pixels high. For example, use the <img src> tag in your web page to include a copy of the Statue of Liberty on your web page. You can also use the <a href> tag to link your image to the TerraServer image page.

HTML TagsResults
<a href="http://terraserver-usa.com/image.aspx?T=1&S=10&X=2903&Y=22523&Z=18&w=1">
<img src="http://terraserver-usa.com/tile.ashx?T=1&S=10&X=2903&Y=22523&Z=18" width=200 height=200 border=0 alt="Statue of Liberty">
</a>
Statue of Liberty

Image courtesy of the US Geological Survey

The tile.ashx script requires five parameters in order to return a Jpeg or GIF image -- T (data theme), S (image scale), X (relative tile on x-axis), Y (relative tile on y-axis), Z (UTM zone number). Each parameter requires a digit string as follows:

  • T = 1, 2, or 4
    The T parameter identifies the data theme. The value 1 indicates that you want a USGS DOQ (Digital Ortho Quadrangle) aerial image tile. All USGS DOQ tiles are Jpeg images. The value 2 indicates you want a USGS DRG (Digital Raster Graphic) topographic map tile. USGS DRG tiles can be Jpeg or GIF images. The value 4 indicates that you want a USGS Urban Area (High resolution, natural color, ortho-image) tile.
  • S = 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, or 19
    The S parameter identifies the resolution or "scale" of the image tile. Scale 10 identifies 1 meter per pixel resolution data. Scale 11 identifies 2 meter per pixel resolution data. Scale 12 identifies 4 meter per pixel resolution data. Data is not available for all themes in all resolutions. DOQ data is available from Scale 10 through Scale 19. DRG data is available from Scale 11 through 19. Urban Area data is available from Scale 8 through Scale 19.
  • X = 1 .. 5000
    Identifies the tile offset from the western most edge of the UTM zone. Thus, tiles are numbered left-to-right within a UTM zone. Tile # X=50 is adjacent to and west of Tile # X=51.
  • Y = 0 .. 50000
    Identifies the tile offset from the southern most edge of the UTM zone. Thus, tiles are numbered bottom-to-top within a UTM zone. Tile # Y=2000 is adjacent to and south of Tile # Y=2001.
  • Z = 1 .. 60
    Identifies UTM zone of the data. All USGS data is projected into the Universe Transverse Mercator projection using the North American Datam of 1983 (NAD83). UTM zones are 6 degrees wide. Zone 1 begins at the International Date Line and are sequentially numbered west-to-east. The conterminous United States is in Zone 10 through 19 as depicted below:

The following is the valid Scale values for each Theme. The diagram on the right shows how the zones sub-divide the conterminous United States.

Theme Scale
Value
Resolution
(Meters Per Pixel)
UTM
Multiplier
Urban 8 .25 50
Urban 9 .5 100
DOQ, Urban 10 1 200
DOQ, DRG, Urban 11 2 400
DOQ, DRG, Urban 12 4 800
DOQ, DRG, Urban 13 8 1600
DOQ, DRG, Urban 14 16 3200
DOQ, DRG, Urban 15 32 6400
DOQ, DRG, Urban 16 64 12800
DOQ, DRG, Urban 17 128 25600
DOQ, DRG, Urban 18 256 51200
DOQ, DRG, Urban 19 512 102400
Digital Orthophoto Quadrangles

Converting TerraServer Tile Parameter Values to UTM Coordinates

All USGS imagery stored in TerraServer is projected in UTM NAD83. The X and Y tile identifiers can easily be converted to the UTM coordinates by multiplying the X and Y tile identifier by the muliplier value associated with the Scale number. For example, the one-meter resolution Statue of Liberty tile has an X tile value of 2903, a Y tile value of 22523. The Scale 10 multiplier is 200 and a Z value of 18. Thus the UTM address of the tile is 580600 easting (2903 X 200), 4504600 northing (22523 X 200) in UTM zone 18. It is the lower left hand corner point of the tile that has this address. The other corner points can be calculated by adding the multiplier to the easting and northing values.

If you have a UTM easting, northing, and zone value, then you can compute the TerraServer tile address by doing the reverse calculation. Say you knew the Golden Gate Bridge was at 545,700 easting, 4,186,400 northing, and in zone 10. What would the 16-meter resolution tile address be? The answer is to divide the easting and northing UTM value and "drop" any fraction.

  • 545,700 / 3200 = 170.53125 = 170 X
  • 4,186,400 / 3200 = 1308.25 = 1308 Y

Thus the UTM address 545,700 easting, 4,186,400 northing, and zone 10 would equate to the TerraServer tile address X=170, Y=1308 and Z=10. Try clicking on http://terraserver-usa.com/image.aspx?T=1&S=14&X=170&Y=1308&Z=10&W=0 to see if our example works.

Converting TerraServer Tile Addresses from One Resolution to Another

Simple arithmetic can be applied to a Tile's X and Y value to compute the parent (lower resolution tile) or child tile (higher resolution tile). Using our Golden Gate Bridge example, suppose we wanted to view the Golden Gate Bridge at 32 meter resolution. What would the tile address be?

To go from a high resolution tile to a lower resolution tile, simply divide by 2 raised to the difference in the low resolution scale number minus the high resolution scale number. In our example, the 16-meter tile address is X=170, Y=1308, Z=10, and S=14. The Scale value for 64-meter tile is 16. Thus we divide the X and Y value by 216 - 14, which equals 22 , which equals 4. Like before, we drop any fraction. Thus, the 64-meter tile address that contains the Golden Gate Bridge is X=42, Y=327, Z=10, and S=16.

The math for computing a high resolution tile from a low resolution tile is similar. Instead of dividing the X and Y value by 2high scale - low scale, the operation is multiply.

Building a TerraServer image larger than 200 x 200 pixels

We picked 200 x 200 pixel tiles on TerraServer so that we could dynamically change the size of an image on an HTML web page. On the TerraServer web site, we offer small (600 x 400 pixel), medium (800 x 600 pixel), and large (1000 x 800 pixel) image sizes. We use HTML table format several 200 x 200 pixel tiles together to form a small, medium, or large image. To build a web page with more than one image tile, our code begins to surround the "center tile of reference" with additional tiles. The logic in our code simply subtracts or adds one to the X and Y address to compute the adjacent tiles.

The "center tile of reference" in our Statue of Liberty example at the top of this page is X=2903, Y=22523, Z=18 and S=10 (1-meter resolution). A medium size image in the TerraServer application requires a table of 2 rows with 3 tiles each. The "center tile of reference" would be the middle tile on the second row. The following is the tile addresses of the "center tile of reference" (displayed in red), and the surrounding tiles:

X=2902 Y=22524 Z=18 S=10 X=2903 Y=22524 Z=18 S=10 X=2904 Y=22524 Z=18 S=10
X=2902 Y=22523 Z=18 S=10 X=2903 Y=22523 Z=18 S=10 X=2904 Y=22523 Z=18 S=10

The resulting image looks like this:

Statue of Liberty Statue of Liberty Statue of Liberty
Statue of Liberty Statue of Liberty Statue of Liberty

When forming HTML tables like the one above, make sure you set the table's border, cellspacing, and cellpadding properties to zero (0).

back buttonhome page button