Extract DEM data from USACE LIDAR Test via ESRI Rest Service


In [1]:
import json
import urllib2

In [2]:
serviceURL='http://gis.sam.usace.army.mil/server/rest/services/JALBTCX/NCMP_BareEarth_1m/ImageServer'

In [13]:
# Get general image service info: Spatial reference, Pixel Type, etc
def getISinfo(serviceURL):
    
    try:
        # Sending request for general service info
        post_data = ""
        
        headers = {}
        headers["Content-Type"] = "application/x-www-form-urlencoded"
        
        serviceURL = serviceURL.replace("arcgis/services", "arcgis/rest/services")+"?f=json"                
        
        # Send general server request
        req = urllib2.Request(serviceURL, post_data, headers)
        response_stream = urllib2.urlopen(req)
        response = response_stream.read()    
        
        jsondict = json.loads(response)    
        isprj = jsondict["extent"]["spatialReference"]
        pixtype = jsondict["pixelType"]
        defaultrr = jsondict["rasterFunctionInfos"][0]["name"]
        
        return isprj, pixtype, defaultrr
    except Exception,e: 
        print str(e)

In [14]:
isprj, pixtype, defaultrr = getISinfo(serviceURL)


'extent'
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-14-358beef29d91> in <module>()
----> 1 isprj, pixtype, defaultrr = getISinfo(serviceURL)

TypeError: 'NoneType' object is not iterable

In [ ]:
print isprj
print pixtype
print defaultrr

In [5]:
serviceURL


Out[5]:
'http://gis.sam.usace.army.mil/server/rest/services/JALBTCX/NCMP_BareEarth_1m/ImageServer'

In [ ]: