• API
• FAQ
• Tools
• Archive
daily pastebin goal
14%
SHARE
TWEET

# Untitled

a guest Jan 22nd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #!/usr/bin/env python3
2. # -*- coding: utf-8 -*-
3. """
4. Created on Mon Jan 14 20:23:30 2019
5.
6. @author: Rodolfo Escobar
7. """
8. import matplotlib.pyplot as plt
9. from matplotlib.ticker import StrMethodFormatter
10. import numpy as np
11.
12. #Dimensiones y tipo de datos
13. X = 5950 # Columnas
14. Y = 6999 # Renglones
15. dim = (Y,X)
16. dtype = np.dtype('uint8') # 1 byte por pixel
17.
18. # Leer .bil
19. fid = open("e14a69e.bil", 'rb')
20. data = np.fromfile(fid, dtype)
21. image = data.reshape(dim)
22.
23. #Recorte de imagen
24. xMin = 1650
25. xMax = 2900
26.
27. yMin = 0
28. yMax = 1250
29.
30. sub_image = image[yMin:yMax,xMin:xMax]
31. #
32.
34. def deg2dec(g,m,s):
35.     """
36.     función de conversión de formato gms
37.     a decimal
38.     """
39.     return g+m/60.+s/(3600.)
40.
41. minLat = deg2dec(20,37,30)
42. maxLat = deg2dec(20,45,00)
43.
44. minLon = deg2dec(89,53,20)
45. maxLon = deg2dec(89,46,40)
46.
47. bx = minLon
48. ax = (maxLon - bx)/X
49.
50. by = minLat
51. ay = (maxLat - by)/Y
52.
53. def Lon(pixel):
54.     return ax*pixel+bx
55.
56. def Lat(pixel):
57.     return ay*pixel+by
58. #
59.
60. #Grafica
61. plt.imshow(sub_image, cmap = 'gray',extent=([Lon(xMin),Lon(xMax),Lat(yMin),Lat(yMax)]))
62. plt.xlabel("Longitud")
63. plt.ylabel("Latitud")
64. plt.title("Jojutla (1995)")
65. plt.gca().xaxis.set_major_formatter(StrMethodFormatter('{x:,.2f}')) # 2 decimales en x
66. plt.gca().yaxis.set_major_formatter(StrMethodFormatter('{x:,.2f}')) # 2 decimales en y
67. plt.grid(True)
68. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top