OpenStreetMap logo OpenStreetMap

Downloading the USGS's Data

Posted by asciipip on 8 July 2011 in English. Last updated on 13 June 2012.

The US Geological Survey has a lot of data, some of which is available via WMS, and some of which is not. They'll give you any of it for free if you ship them a hard drive to put it on, but that can be both inconvenient (waiting weeks for the drive's round trip) and imprecise (they will only send entire datasets, even if you're only interested in a small portion of one). You can also download data from their seamless server, but downloading is a pain: you have to select an area (which must contain less than 1.5 GB of data in all), then their servers will divide that data into sub-250MB chunks and put the chunks on a webserver with randomly-generated filenames which will be deleted after an hour.

Fortunately, the USGS has recently implemented a set of web services that let you write programs to download chunks of data from them.

I've written a simple python program, get_usgs_data, to download all data for a dataset within a given region.

The program requires wget and the Suds and BeautifulSoup python modules. To use it, run get_usgs_data --bbox=left,bottom,right,top product, where left, right, top, and bottom are bounding coordinates in WGS84 and product is a valid USGS product ID. You can query for product IDs with the online index service. Look for one of the "return_Attributes" calls; the string you need is in the PRODUCTKEY attribute.

Addendum:

More information on getting the right product key.

The return_Attribute_List SOAP call lists the informational fields available for each dataset. It takes no parameters, so just click through to its service page and click the "Invoke" button. I usually use a combination of AREA_NAME, RESOLUTION, TYPE, and of course PRODUCTKEY. Basically, you want enough information to tell which product key corresponds to the dataset you want.

Next, go to one of the return_Attributes calls. The plain return_Attributes call will search all available datasets. The ones ending with _Elevation, _LandCover, and _Ortho search specific types of datasets. (The _EO appears to be similar, but I don't know what it stands for.) On the service page for the call you want, enter the attributes you want to see in a comma delimited list (e.g. "AREA_NAME,RESOLUTION,TYPE,PRODUCTKEY") and the rough bounds for the area you're interested in. (I'm often lazy and just use -180,0,0,90.) You also have to enter the EPSG code for the coordinate system you're using. Lat/lon coordinates are 4326.

After that, just look through the returned XML and figure out what the product key you want is.

Discussion

Log in to leave a comment