Changeset 2518


Ignore:
Timestamp:
Mar 9, 2006, 5:22:30 PM (18 years ago)
Author:
sexton
Message:

fixed dem2pts AGAIN!!! to remove NODATA values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/data_manager.py

    r2516 r2518  
    12021202    # calculating number of NODATA_values for each row
    12031203    nn = 0
    1204     no_counts = []
    12051204    for i in range(nrows):
    1206         v = dem_elevation_r[i,:]
    1207         this_count = sum(v == NODATA_value)
    1208         nn += this_count
    1209         no_counts.append(this_count)
    1210 
    1211     if verbose and nn > 0:
    1212         print 'There are %d values in the elevation' %totalnopoints
    1213         print 'There are %d NODATA_values in the elevation' %nn
    1214    
     1205        y = (nrows-i)*cellsize + yllcorner
     1206        for j in range(ncols):
     1207            x = j*cellsize + xllcorner
     1208            if easting_min <= x <= easting_max and \
     1209               northing_min <= y <= northing_max and \
     1210               dem_elevation_r[i,j] == NODATA_value:
     1211                nn += 1
     1212       
    12151213    # dimension definitions
    12161214    nrows_in_bounding_box = int(round((northing_max-northing_min)/cellsize))
    12171215    ncols_in_bounding_box = int(round((easting_max-easting_min)/cellsize))
    1218    
    1219     nopoints = nrows_in_bounding_box*ncols_in_bounding_box-nn
    1220     #nopoints = nrows_in_bounding_box*ncols_in_bounding_box
     1216
     1217    clippednopoints = nrows_in_bounding_box*ncols_in_bounding_box
     1218    nopoints = clippednopoints-nn
     1219
     1220    if verbose and nn > 0:
     1221        print 'There are %d values in the elevation' %totalnopoints
     1222        print 'There are %d values in the clipped elevation' %clippednopoints
     1223        print 'There are %d NODATA_values in the clipped elevation' %nn
     1224   
    12211225    outfile.createDimension('number_of_points', nopoints)
    12221226    outfile.createDimension('number_of_dimensions', 2) #This is 2d data
     
    12391243        lower_index = global_index
    12401244       
    1241         no_NODATA = no_counts[i]
     1245        v = dem_elevation_r[i,:]
     1246        no_NODATA = sum(v == NODATA_value)
    12421247        if no_NODATA > 0:
    12431248            newcols = ncols_in_bounding_box - no_NODATA
     
    22902295    number_of_latitudes = latitudes.shape[0]
    22912296    number_of_longitudes = longitudes.shape[0]
    2292 
    2293     msg = 'No data received'
    2294     assert latitudes.shape[0] > 0, msg
    2295     assert longitudes.shape[0] > 0, msg
    22962297
    22972298    assert amplitudes.shape[0] == number_of_times
Note: See TracChangeset for help on using the changeset viewer.