I am building a website that must gather information from the USGS' various APIs but seem to have a hard time.

I'm trying to obtain the Soil Type using the Vs30 API. Here is the link for the documentation: http://earthquake.usgs.gov/hazards/apps/vs30/documentation.php.

So far I'm receiving information from USGS in the correct form, yet the files are either empty or simply do not exist. Each file 'size' is returned 'false' and following the url provided lands me on the 'page not found' page. I am using jQuery.ajax() to call a php document using cURL to post my request. As stated before, I get the correct format returned, yet the files are unusable. Using wget through bash has also return empty files.

Here is my code for the Vs30 API:


var dataObj = {
        json: 'true', 
        site_name: 'model', 
        top_left_lat: 34.00, 
        top_left_lon: -122.00,
        bottom_right_lat: 34.01, 
        bottom_right_lon: -121.99, 
        slope_type: 'stable',
        output_types: ['jpg', 'txt', 'grd']

    url: /php/vs30.php,
    type: 'POST',
    dataType: 'json',
    crossDomain: true,
    data: dataObj,
    success: function(data) {


$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => 'http://earthquake.usgs.gov/hazards/apps/vs30/vs30.php',
    CURLOPT_USERAGENT => 'Codular Sample cURL Request',
    CURLOPT_POST => 1,
    CURLOPT_POSTFIELDS => "json=true&site_name=model&top_left_lat=34&top_left_lon=-122&bottom_right_lat=33.89&bottom_right_lon=-122.11&slope_type=stable&output_types[]=jpg&output_types[]=xyz&output_types[]=grd"
$resp = curl_exec($curl);
echo $resp;

As you can see, I have hard coded the request inside the PHP script temporarily. Here is the response I get from USGS:

Chrome Console:

Object {jpg: Object, grd: Object, xyz: Object}
grd: Object
    size: false
    url: "http://ehp3-earthquake.wr.usgs.gov/hazards/apps/vs30/output/model/1403106400.grd.gz"
    __proto__: Object
jpg: Object
    size: false
    thumb: "http://ehp3-earthquake.wr.usgs.gov/hazards/apps/vs30/output/model/1403106400_thumb.jpg"
    url: "http://ehp3-earthquake.wr.usgs.gov/hazards/apps/vs30/output/model/1403106400.jpg"
    __proto__: Object
xyz: Object
    size: false
    url: "http://ehp3-earthquake.wr.usgs.gov/hazards/apps/vs30/output/model/1403106400.txt.gz"
    __proto__: Object
__proto__: Object

I think that the other API calls (GET http requests) are relatively the same process, so if I get this figured out, I can call the other APIs with no problem. If my thinking is wrong, please let me know and how to go about the other APIs (geohazards . usgs . gov/hazardtool/application.php <-- Click on the tab "Data Access", and earthquake . usgs . gov/hazards/designmaps/usdesigndoc.php <-- located at the bottom of the page).

Sorry for the broken links, I cannot post more than two... I am new to cross domain communication therefore new to cURL. Any advice would be very helpful!


1 Answer 1


I looks like you have your left/right longitude values mixed up. Try fixing this and post back your results.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.