Skip to Content

traitement avec numpy

  1. import numpy as np
  2. m = 12609
  3. n = 8810
  4.  
  5. # matrice des pixels:
  6. fp = np.matrix([[1,m,m,1],[1,1,n,n]])
  7. # ajout des cordonnées homogènes
  8. newligne = [1,1,1,1]
  9. fp = np.vstack([fp,newligne])
  10. print fp
  11. matrix([[ 1, 12609, 12609, 1],
  12. [ 1, 1, 8810, 8810],
  13. [ 1, 1, 1, 1]])
  14. # matrice des coordonnées
  15. tp = np.matrix([[1616411.91,1617482.52,1617503.82,1616433.22],[9173672.33,9173641.84,9174389.85,9174420.34]])
  16.  
  17. # solution = fp x inverse(tp)
  18. M = tp * fp.I
  19. print M
  20. matrix([[ 8.49147367e-02, 2.41854921e-03, 1.61641183e+06],
  21. [ -2.41830584e-03, 8.49142922e-02, 9.17367225e+06]])
  22.  
  23. # paramètres
  24. A = M[:, 0][0]
  25. B = M[:, 1][0]
  26. C = M[:, 2][0]
  27. D = M[:, 0][1]
  28. E = M[:, 1][1]
  29. F = M[:, 2][1]
  30.  
  31. # dans l'ordre d'un worldfile
  32. >>> print A,D,B,E,C,F
  33. [[ 0.08491474]] [[-0.00241831]] [[ 0.00241855]] [[ 0.08491429]] [[ 1616411.82516671]] [[ 9173672.24750401]]