Skip to content

Commit

Permalink
Changed estimate of spatial resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
kcartier-wri committed Aug 30, 2024
1 parent fecab97 commit c820296
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tests/test_layer_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def validate_layer_instance(obj_string):

def evaluate_layer(layer, expected_resolution):
data = layer.get_data(BBOX)
actual_estimated_resolution, uu = get_spatial_resolution_estimate(data)
print ('uu %s' % uu)
actual_estimated_resolution = get_spatial_resolution_estimate(data)
assert expected_resolution == actual_estimated_resolution

def get_spatial_resolution_estimate(data):
Expand All @@ -117,16 +116,21 @@ def get_spatial_resolution_estimate(data):
y_max = data['y'].values.max()

crs = CRS.from_string(data.crs)
uu = crs.axis_info[0].unit_name
if uu == 'metre':
crs_units = crs.axis_info[0].unit_name
if crs_units == 'metre':
y_diff = y_max - y_min
else:
elif crs_units == 'foot':
feet_to_meter = 0.3048
y_diff = (y_max - y_min) * feet_to_meter
elif crs_units == 'degree':
lat1 = y_min
lat2 = y_min
lat2 = y_max
lon1 = data['x'].values.min()
lon2 = data['x'].values.max()
lon2 = lon1
y_diff = get_distance_between_geocoordinates(lat1, lon1, lat2, lon2)
else:
raise Exception('Unhandled projection units: %s' % crs_units)

ry = round(y_diff / y_cells)

return ry, uu
return ry

0 comments on commit c820296

Please sign in to comment.