
    nj&0                         S SK r S SKrS SKrS SKJrJr   S rS rS rS r	S r
S rSS	 jr\R                  4S
 jr\S:X  a#  \R                   " \" \R                  5      5        gg)    N)gdal
gdal_arrayc                    U R                  5       R                  5       nUS:w  aB  UR                  S5      S:X  a-  U R                  5       nUS:w  a  UR                  S5      S:X  a  M-  US:X  a  g UR                  S5      nU R                  5       R                  5       nUR                  5       n[	        US   5      [	        US   5      S-  -   [	        US   5      S	-  -   n[	        US
   5      [	        US   5      S-  -   [	        US   5      S	-  -   nU R                  5       R                  5       nUR                  5       n[	        US   5      [	        US   5      S-  -   [	        US   5      S	-  -   n[	        US
   5      [	        US   5      S-  -   [	        US   5      S	-  -   n[        US   5      [        US   5      UUUU4$ )N PNT__      g      N@   g      @         )readlinestripfindsplitfloatint)fdlinename_tokenstokenslat_srclat_dstlon_srclon_dsts           \/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/osgeo_utils/samples/crs2crs2grid.py
next_pointr   4   s   ;;= D
"*6*b0{{} "*6*b0 rz**S/K ;;= DZZ\FF1Ivay!1D!885;Kf;TTGF1Ivay!1D!885;Kf;TTG;;= DZZ\FF1Ivay!1D!885;Kf;TTGF1Ivay!1D!885;Kf;TTG 	KNKN     c                    [        U 5      n[        R                  " U5      n[        S5       H*  n[	        UR                  5       R                  5       5        M,     Sn[        U5      nUbC  US   US   -
  USUS   US   4'   US   US   -
  USUS   US   4'   US-   n[        U5      nUb  MC  XQS   US   -  :  a"  [	        SU5        [	        SUS   US   -  5        g U$ )	Nr   r      r   r
   r   zpoints found:   zpoints expected:)opennumpyzerosrangeprintr   rstripr   )filenameshaper   gridr	   points_foundptuples          r   read_grid_crs_to_crsr.   V   s    	hB;;uD 1Xbkkm""$%  L^F

(.q	F1I(=Qq	6!9$%(.q	F1I(=Qq	6!9$%#a'B	 
 Ahq)) ,/ %(U1X"56Kr    c                 D   SU S   -  nSU S   -  nU S   nU S   nU S   nU S   n[         R                  " X4U5      n[         R                  " XU5      nU/U-  n	[         R                  " U	5      n
U/U-  n[         R                  " U5      n[         R                  " X/5      $ )Nr   r   r   r
   r   r"   r   )r$   linspacevstackcolumn_stackarray)griddef	lon_startlon_end	lat_startlat_end	lon_steps	lat_stepslat_axislon_axislon_listlon_bandlat_listlat_bands                r   new_create_gridrA   u   s    WQZI71:oG
IajG
I
I~~i)<H~~i)<HzI%H||H%HzI%H!!(+H;;+,,r    c           
          [        US5      n[        U R                  S   5       HC  n[        U R                  S   5       H$  nUR                  SU SXC4   U SXC4   X44-  5        M&     ME     UR	                  5         g )Nwr   r
   z%f %f 0 "PNT_%d_%d"
r   )r#   r&   r*   writeclose)r+   out_filenamefd_outijs        r   
write_gridrJ      sq    ,$F4::a=!tzz!}%ALL0DAM41=RS3WWX & " LLNr    c                    US   US   -
  US   S-
  -  nUS   US   -
  US   S-
  -  nUS   US-  -
  USUS   US-  -
  SU4nUR                  [        R                  5      n[        R                  " XS	S
9nUR                  U5        g )Nr   r   r"   r
   r   r   g      ?g        CTable2)format)astyper$   float32r   	SaveArraySetGeoTransform)r)   r+   r4   ps_xps_ygeotransformdss          r   write_gdal_gridrV      s    AJ#
Q7DAJ#
Q7D
TCZ
TCZL ;;u}}%D			dY	?B|$r    c                 T    SnUUUUUUU4-  n[        U S5      R                  U5        g )Nz
4
%s
%d
%d
2
%s
2
%s
3
%s
0
0
rC   )r#   rD   )	
control_fnout_grid_fn
in_grid_fn
src_crs_idsrc_crs_date
dst_crs_iddst_crs_datecontrol_templatecontrol_filleds	            r   write_controlra      sD     &) N 	S/r    c                 <    [        S5        U S:X  a  [        S5        g)Na  
Usage: crs2crs2grid.py
        <src_crs_id> <src_crs_date> <dst_crs_id> <dst_crs_year>
        [-griddef <ul_lon> <ul_lat> <ll_lon> <ll_lat> <lon_count> <lat_count>]
        [-htdp <path_to_exe>] [-wrkdir <dirpath>] [-kwf]
        -o <output_grid_name>

 -griddef: by default the following values for roughly the continental USA
           at a six minute step size are used:
           -127 50 -66 25 251 611
 -kwf: keep working files in the working directory for review.

eg.
 crs2crs2grid.py 29 2002.0 8 2002.0 -o nad83_2002.ct2
 r   a  
The output file will be in CTable2 format suitable for use with PROJ.4
+nadgrids= directive.

Format dates like 2002.0 (for the start of 2002)

CRS Ids
-------
  1...NAD_83(2011) (North America tectonic plate fixed)
  29...NAD_83(CORS96)  (NAD_83(2011) will be used)
  30...NAD_83(2007)    (NAD_83(2011) will be used)
  2...NAD_83(PA11) (Pacific tectonic plate fixed)
  31...NAD_83(PACP00)  (NAD 83(PA11) will be used)
  3...NAD_83(MA11) (Mariana tectonic plate fixed)
  32...NAD_83(MARP00)  (NAD_83(MA11) will be used)

  4...WGS_72                             16...ITRF92
  5...WGS_84(transit) = NAD_83(2011)     17...ITRF93
  6...WGS_84(G730) = ITRF92              18...ITRF94 = ITRF96
  7...WGS_84(G873) = ITRF96              19...ITRF96
  8...WGS_84(G1150) = ITRF2000           20...ITRF97
  9...PNEOS_90 = ITRF90                  21...IGS97 = ITRF97
 10...NEOS_90 = ITRF90                   22...ITRF2000
 11...SIO/MIT_92 = ITRF91                23...IGS00 = ITRF2000
 12...ITRF88                             24...IGb00 = ITRF2000
 13...ITRF89                             25...ITRF2005
 14...ITRF90                             26...IGS05 = ITRF2005
 15...ITRF91                             27...ITRF2008
                                         28...IGS08 = ITRF2008
r   )r'   briefs    r   Usagere      s+    		$ z	
B r    c           
         [         R                  " U 5      n U c  g[        U 5      S:X  a	  [        SS9$ S nS nS nS nSnSnSnSnS n	Sn
U
[        U 5      :  Ga  X
   S:X  au  U
[        U 5      S-
  :  ac  [	        X
S-      5      [	        X
S	-      5      [	        X
S
-      5      [	        X
S-      5      [	        X
S-      5      [	        X
S-      5      4nU
S-   n
GO
X
   S:X  a  U
[        U 5      S-
  :  a  X
S-      nU
S-   n
OX
   S:X  a  SnOX
   S:X  a  U
[        U 5      S-
  :  a  X
S-      nU
S-   n
OX
   S:X  a  U
[        U 5      S-
  :  a  X
S-      n	U
S-   n
OX
   S:X  d  X
   S:X  a	  [        SS9$ X
   S   S:X  a  [        SX
   -   5        [        5       $ Uc  [        X
   5      nO;Uc  X
   nO3Uc  [        X
   5      nO"Uc  X
   nO[        SX
   -   5        [        5       $ U
S-   n
U
[        U 5      :  a  GM  U	c  [        S5        [        5       $ Uc  [        S5        [        5       $ US:  d  US:  d  US:  d  US:  a  [        SX4-  5        [        SS9$ [	        U5      S:  d-  [	        U5      S:  d  [	        U5      S:  d  [	        U5      S:  a  [        SU< SU< S35        [        SS9$ US-   nUS-   nUS-   n[        U5      n[        X5        [        UUUUUUU5         [        R                  " U5        [        R                  " US -   U-   5      nUS:w  a  [        S!5        g[        S"5        [        XR                  5      nUc  gUS#-  n[!        U	UU5        US:X  aB  [        R                  " U5        [        R                  " U5        [        R                  " U5        [        S$U	-   5        g! [         a     Nf = f)%Nr   r
   rc   )g     _g      I@g     Pg      9@ic     htdp.z-griddefr   r   r   r"   r   z-htdpz-kwfz-wrkdirz-oz-hz--help-zUrecognised argument: zMissing output grid name (-o)zISource and Destination CRS Ids and Dates are mandatory, not all provided.    z/Invalid source or destination CRS Id %d and %d.g     @g     @z)Source or destination CRS date seems odd z and z/crs2crs_input.txtz/crs2crs_output.txtz/crs2crs_control.txtz < zhtdp run failed!zhtdp run complete.g9RFߑ?zProcessing complete: see )r   GeneralCmdLineProcessorlenre   r   r'   r   rA   rJ   ra   osunlinkOSErrorsystemr.   r*   rV   )argvr[   r\   r]   r^   r4   	htdp_pathwrkdirkwfoutput_grid_namerH   rZ   rY   rX   r+   rc
adjustments                    r   mainry     s    ''-D|
4yA~1~ JLJL 4GIF
C 	
A
c$i-7j QTQ%6dq5k"dq5k"dq5k"dq5k"dq5k"dq5k"G AAWAD	A$5UIAAWCW	!a#d)a-&7a%[FAAW_SY]!2#E{AAW_8 3q>!WQZ3*TW457NTWJ!7LTWJ!7L *TW457NEg c$i-l -.w 	
 w A~bJNj2o=@XX	
 1~ 	lf$'''\+	
 1~ ..J00K00J 7#Dt 
		+ 
9u$z1	2B	Qw !	
%k::>J =>J $j': ax
		*
		+
		*	
%(8
897  s   %N6 6
OO__main__)r
   )rn   sysr$   osgeor   r   r   r.   rA   rJ   rV   ra   re   rr   ry   __name__exit r    r   <module>r      sr   B 
 
  "D>-8%*$0T5x hh aH zHHT#((^ r    