Skip to content

Commit c629dc4

Browse files
committed
Do not save redundant data (keep total filesize similar to what it has been)
1 parent f5ad9c4 commit c629dc4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

utils/readboundaries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def quantize(data,least_significant_digit):
2323
return np.around(scale*data)/scale
2424

2525
def interpolate_long_segments(coords, resolution):
26-
lookup_thresh = {'c': 0.5, 'l':0.1, 'i':0.05, 'h':0.01, 'f':0.005}
26+
lookup_thresh = {'c': 0.5, 'l':0.3, 'i':0.2, 'h':0.1, 'f':0.05}
2727
thresh = lookup_thresh[resolution]
2828
spacing = thresh / 5.0
2929

utils/readboundaries_shp.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def quantize(data,least_significant_digit):
3131
return np.around(scale*data)/scale
3232

3333
def interpolate_long_segments(coords, resolution):
34-
lookup_thresh = {'c': 0.5, 'l':0.1, 'i':0.05, 'h':0.01, 'f':0.005}
34+
lookup_thresh = {'c': 0.5, 'l':0.3, 'i':0.2, 'h':0.1, 'f':0.05}
3535
thresh = lookup_thresh[resolution]
3636
spacing = thresh / 5.0
3737

@@ -119,7 +119,9 @@ def get_wdb_boundaries(resolution,level,rivers=False):
119119
b[:,0] = lons; b[:,1] = lats
120120
if lsd is not None:
121121
b = quantize(b,lsd)
122-
b = interpolate_long_segments(b, resolution)
122+
123+
if not rivers:
124+
b = interpolate_long_segments(b, resolution)
123125

124126
polymeta.append([-1,-1,south,north,len(b),poly_id])
125127
polybounds.append(b)
@@ -178,7 +180,10 @@ def get_wdb_boundaries(resolution,level,rivers=False):
178180
for resolution in ['c','l','i','h','f']:
179181
f = open(os.path.join(OUTPUT_DIR, 'rivers_'+resolution+'.dat'), 'wb')
180182
f2 = open(os.path.join(OUTPUT_DIR, 'riversmeta_'+resolution+'.dat'), 'w')
181-
for level in range(1,12):
183+
# Levels above 5 are intermittent rivers and irrigation canals.
184+
# They haven't been included in the past, as far as I can tell, so I'm
185+
# not including them here...
186+
for level in range(1, 6):
182187
poly, polymeta = get_wdb_boundaries(resolution,level,rivers=True)
183188
offset = 0
184189
for p,pm in zip(poly,polymeta):

0 commit comments

Comments
 (0)