def get_north_shifted_point(dem,offset=0.001):
    newPoint = Point(lon=dem.center.lon, lat=dem.center.lat+offset)
    newPoint.lonlat_to_pixel(dem.geotransform, dem.projection)
    return newPoint
Exemple #2
0
aspects = ImgData(os.path.join(folder,'big_spider_aspects.tif'))
# spider1 = ImgData(os.path.join(folder,'ESP_022607_0985_cropped_big_spider.cub'))
# spider2 = ImgData(os.path.join(folder,'ESP_022699_0985_cropped_big_spider.cub'))

# read in required data
dem.read_all()
slopes.read_all()
aspects.read_all()

# plt.imshow(dem.data,aspect='auto')
# plt.plot(dem.center.sample,dem.center.line, 'r*',markersize=10)

# determine angle between north and top to correct aspect angles that count like
# north is at the top of the image
newPoint = Point(lon=dem.center.lon, lat=dem.center.lat+0.001)
newPoint.lonlat_to_pixel(dem.geotransform, dem.projection)
# plt.plot(newPoint.sample, newPoint.line, 'g*', markersize=10)
v1 = np.array((newPoint.x - dem.center.x, newPoint.y - dem.center.y))
# delta between north and top of image
delta_angle = np.degrees(np.arctan2(v1[1],v1[0]))-90.0
# dsample = newPoint.sample - dem.center.sample
# dline = newPoint.line - dem.center.line
# plt.quiver(dem.center.sample,dem.center.line,dsample,dline,angles='xy', scale_units='xy', scale=1)

# correct aspects for delta angle
# it needs to be added, because aspects go clock-wise
aspects.data += delta_angle
# bend around data > 360
mask = aspects.data > 360.0
aspects.data[mask] = aspects.data[mask] - 360.0