Ignore:
Timestamp:
Nov 24, 2005, 10:46:22 AM (18 years ago)
Author:
ole
Message:

Made asc and ers formats use the same method for assigning missing values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/data_manager.py

    r2057 r2060  
    14241424            reduction = None,
    14251425            cellsize = 10,
     1426            NODATA_value = -9999,
    14261427            easting_min = None,
    14271428            easting_max = None,
     
    14811482    msg = 'Format must be either asc or ers'
    14821483    assert format.lower() in ['asc', 'ers'], msg
    1483    
     1484
     1485       
    14841486    false_easting = 500000
    14851487    false_northing = 10000000
     
    16701672    grid_values = interp.interpolate(q).flat
    16711673
     1674
     1675    #Assign NODATA_value to all points outside bounding polygon (from interpolation mesh)
     1676    P = interp.mesh.get_boundary_polygon()
     1677    inside_indices = inside_polygon(grid_points, P)
     1678
     1679    #FIXME: Remove when new interpolation takes care of this
     1680    for i in range(nrows):
     1681        if verbose and i%((nrows+10)/10)==0:
     1682            print 'Doing row %d of %d' %(i, nrows)
     1683
     1684        base_index = (nrows-i-1)*ncols     
     1685        for j in range(ncols):
     1686            index = base_index+j
     1687
     1688            if not sometrue(inside_indices == index):
     1689                grid_values[index] = NODATA_value
     1690
     1691    #############           
     1692
     1693   
     1694
    16721695    if verbose:
    16731696        print 'Interpolated values are in [%f, %f]' %(min(grid_values),
     
    16771700        # setup ERS header information
    16781701        grid_values = reshape(grid_values,(nrows, ncols))   
    1679         NODATA_value = 0
    16801702        header = {}
    16811703        header['datum'] = '"' + datum + '"'
     
    17251747   
    17261748        if verbose: print 'Writing %s' %demfile
    1727         NODATA_value = -9999
    17281749 
    17291750        ascid = open(demfile, 'w')
     
    17381759
    17391760        #Get bounding polygon from mesh
    1740         P = interp.mesh.get_boundary_polygon()
    1741         inside_indices = inside_polygon(grid_points, P)
     1761        #P = interp.mesh.get_boundary_polygon()
     1762        #inside_indices = inside_polygon(grid_points, P)
    17421763
    17431764        for i in range(nrows):
     
    17451766                print 'Doing row %d of %d' %(i, nrows)
    17461767
     1768            base_index = (nrows-i-1)*ncols     
    17471769            for j in range(ncols):
    1748                 index = (nrows-i-1)*ncols+j
    1749 
    1750                 if sometrue(inside_indices == index):
    1751                     ascid.write('%f ' %grid_values[index])
    1752                 else:
    1753                     ascid.write('%d ' %NODATA_value)
     1770                index = base_index+j
     1771
     1772                ascid.write('%f ' %grid_values[index])
    17541773
    17551774            ascid.write('\n')
Note: See TracChangeset for help on using the changeset viewer.