Ignore:
Timestamp:
Mar 16, 2006, 5:35:18 PM (17 years ago)
Author:
sexton
Message:

maybe this is it for dem2pts ...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/data_manager.py

    r2541 r2553  
    12061206    i1_0 = 0
    12071207    j1_0 = 0
     1208    thisj = 0
     1209    thisi = 0
    12081210    for i in range(nrows):
    1209         y = (nrows-i)*cellsize + yllcorner
     1211        y = (nrows-i-1)*cellsize + yllcorner
    12101212        for j in range(ncols):
    12111213            x = j*cellsize + xllcorner
    12121214            if easting_min <= x <= easting_max and \
    12131215               northing_min <= y <= northing_max:
     1216                thisj = j
     1217                thisi = i
    12141218                if dem_elevation_r[i,j] == NODATA_value: nn += 1
    12151219
    12161220                if k == 0:
    12171221                    i1_0 = i
    1218                     j1_0 = j 
     1222                    j1_0 = j
    12191223                k += 1   
    12201224
    1221             index1 = j1_0
    1222             index2 = j
    1223             index3 = i1_0
    1224             index4 = i
    1225 
    1226 
    1227     index2 += 1
    1228     nrows2 = index4 - index3
    1229     ncols2 = index2 - index1 + 1
     1225    index1 = j1_0
     1226    index2 = thisj
    12301227   
    12311228    # dimension definitions
     
    12331230    ncols_in_bounding_box = int(round((easting_max-easting_min)/cellsize))
    12341231   
    1235     clippednopoints = nrows_in_bounding_box*ncols_in_bounding_box
     1232    clippednopoints = (thisi+1-i1_0)*(thisj+1-j1_0)
    12361233    nopoints = clippednopoints-nn
    12371234
     1235    clipped_dem_elev = dem_elevation_r[i1_0:thisi+1,j1_0:thisj+1]
     1236   
    12381237    if verbose and nn > 0:
    12391238        print 'There are %d values in the elevation' %totalnopoints
    1240         #print 'There are %d values in the clipped elevation' %clippednopoints
     1239        print 'There are %d values in the clipped elevation' %clippednopoints
    12411240        print 'There are %d NODATA_values in the clipped elevation' %nn
    12421241       
     
    12531252    elevation = outfile.variables['elevation']
    12541253
    1255    
     1254    lenv = index2-index1+1
    12561255    #Store data
    12571256    global_index = 0
    1258     for i in range(nrows):
     1257    #for i in range(nrows):
     1258    for i in range(i1_0,thisi+1,1):
    12591259        if verbose and i%((nrows+10)/10)==0:
    12601260            print 'Processing row %d of %d' %(i, nrows)
     
    12621262        lower_index = global_index
    12631263
    1264         v = dem_elevation_r[i,index1:index2]
     1264        v = dem_elevation_r[i,index1:index2+1]
    12651265        no_NODATA = sum(v == NODATA_value)
    12661266        if no_NODATA > 0:
    1267             newcols = len(v) - no_NODATA #ncols_in_bounding_box - no_NODATA
     1267            newcols = lenv - no_NODATA #ncols_in_bounding_box - no_NODATA
    12681268        else:
    1269             newcols = len(v) #ncols_in_bounding_box
    1270 
    1271         #print 'here', len(v), no_NODATA, newcols, v
    1272         #print 'here again', dem_elevation_r[i,:]
     1269            newcols = lenv #ncols_in_bounding_box
     1270
    12731271        telev = zeros(newcols, Float)
    12741272        tpoints = zeros((newcols, 2), Float)
     
    12761274        local_index = 0
    12771275       
    1278         y = (nrows-i)*cellsize + yllcorner
    1279         for j in range(ncols):
     1276        y = (nrows-i-1)*cellsize + yllcorner
     1277        #for j in range(ncols):
     1278        for j in range(j1_0,index2+1,1):
    12801279
    12811280            x = j*cellsize + xllcorner
Note: See TracChangeset for help on using the changeset viewer.