This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
teaching:m_r:excersize:proj4 [2012/10/10 09:23] 127.0.0.1 external edit |
teaching:m_r:excersize:proj4 [2021/08/14 04:21] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Proj4 ====== | + | ====== |
- | describe how to do with the following tools: | + | |
- | proj4 | + | ===== Proj.4 ===== |
- | awk | + | Reference: [[https:// |
- | script | + | |
+ | |||
+ | PROJ.4 is a library for performing conversions between cartographic projections. The library is based on the work of Gerald Evenden at the USGS,[2] but is now an OSGeo project maintained by Frank Warmerdam. The library also ships with executables for performing these transformations from the command line. (Reference: [[http:// | ||
+ | |||
+ | |||
+ | |||
+ | == Download program == | ||
+ | ^Windows^Mac^Linux^ | ||
+ | |[[http:// | ||
+ | |||
+ | |||
+ | |||
+ | ===== Awk ===== | ||
+ | Awk is a terminal program / script program. | ||
+ | |||
+ | Reference: [[http:// | ||
+ | |||
+ | If you are like many computer users, you would frequently like to make changes in various text files wherever certain patterns appear, or extract data from parts of certain lines while discarding the rest. To write a program | ||
+ | |||
+ | The awk utility interprets a special-purpose programming language that makes it possible to handle simple data-reformatting jobs with just a few lines of code. | ||
+ | |||
+ | Find the manual here: [[http:// | ||
+ | |||
+ | == Download program == | ||
+ | ^Windows^Mac^Linux^ | ||
+ | |[[http:// | ||
+ | |||
+ | ===== Awk/ | ||
+ | Script that convert gga-strings to UTM co-ordinates. | ||
+ | |||
+ | |||
+ | <file bash ggacs2cs.awk> | ||
+ | # | ||
+ | function usage(){ | ||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | print "NFN=3 (input field latitude)" | ||
+ | print "EFN=5 (input field longitude)" | ||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | |||
+ | } | ||
+ | #Windows command: gawk -f ggacs2cs.awk -v ECHO=true PRINT2FILE=true OUTPUTFILE=utm_row4_adana EPSGTO=32636 ggaLog.log | ||
+ | #Windows command: gawk -f ggacs2cs.awk -v PRINT2FILE=true OUTPUTFILE=gga_l_u EPSGTO=32636 GGAlinksoben.log | ||
+ | # | ||
+ | |||
+ | # TODO: feed all coordinates to cs2cs in one large chunk, not line per line | ||
+ | # TODO: use optarg: http:// | ||
+ | BEGIN{ | ||
+ | <<<<<<< | ||
+ | CONVFMT=" | ||
+ | ======= | ||
+ | CONVFMT=" | ||
+ | >>>>>>> | ||
+ | # while ((c = getopt(ARGC, | ||
+ | # if (c == " | ||
+ | # | ||
+ | # }# else if (c == " | ||
+ | #} | ||
+ | |||
+ | if(MYFS=="" | ||
+ | FS="," | ||
+ | } | ||
+ | OFS=FS | ||
+ | if (EPSGTO=="" | ||
+ | EPSGTO=" | ||
+ | } | ||
+ | if (EPSGFROM=="" | ||
+ | EPSGFROM=" | ||
+ | } | ||
+ | if (CNV=="" | ||
+ | CNV=" | ||
+ | } | ||
+ | if(NFN=="" | ||
+ | if(EFN=="" | ||
+ | if(HFN=="" | ||
+ | if(ECHO=="" | ||
+ | if(PRINT2FILE=="" | ||
+ | if(OUTPUTFILE=="" | ||
+ | } | ||
+ | |||
+ | function nmea2dd(nmeacoord){ | ||
+ | dn=int(nmeacoord/ | ||
+ | return dn+((nmeacoord-(dn*100.0))/ | ||
+ | } | ||
+ | function cs2cs(coordarray){ | ||
+ | CMD=" | ||
+ | # | ||
+ | gkarray[0]="" | ||
+ | CMD | getline TRANSFCOORD | ||
+ | # | ||
+ | split(TRANSFCOORD, | ||
+ | split(gkarray[2], | ||
+ | # print C[0] | ||
+ | # GKR=C[1] | ||
+ | # GKH=D[1] | ||
+ | coordarray[7]=gkarray[1] | ||
+ | coordarray[6] = D[1] #northing | ||
+ | coordarray[8] = D[2] #easting | ||
+ | # print " | ||
+ | # | ||
+ | } | ||
+ | |||
+ | # function wgs84toepsg(coord_n_e_h_to){ | ||
+ | # | ||
+ | # # print CMD | ||
+ | # | ||
+ | # CMD | getline TRANSFCOORD | ||
+ | # # | ||
+ | # | ||
+ | # | ||
+ | # # print C[0] | ||
+ | # # GKR=C[1] | ||
+ | # # GKH=D[1] | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # print " | ||
+ | # | ||
+ | # } | ||
+ | {if (ECHO!=" | ||
+ | #if (true){ | ||
+ | # for (i=1; | ||
+ | # print i" | ||
+ | # } | ||
+ | #} | ||
+ | } | ||
+ | /GGA/{ | ||
+ | # | ||
+ | transarray[0]="" | ||
+ | transarray[1]=nmea2dd($NFN) # ddlat | ||
+ | transarray[2]=nmea2dd($EFN) # ddlon | ||
+ | transarray[3]=$HFN # | ||
+ | transarray[4]=EPSGFROM | ||
+ | transarray[5]=EPSGTO | ||
+ | # | ||
+ | cs2cs(transarray) | ||
+ | if(CNV!=" | ||
+ | $1=" | ||
+ | $NFN=transarray[6] | ||
+ | $EFN=transarray[7] | ||
+ | $HFN=transarray[8] | ||
+ | print $0 | ||
+ | }else | ||
+ | print transarray[6] FS transarray[7] FS transarray[8] | ||
+ | #write to file: works in windows | ||
+ | if(PRINT2FILE==" | ||
+ | #{print transarray[6] FS transarray[7] FS transarray[8] > OUTPUTFILE" | ||
+ | # | ||
+ | {print transarray[1] FS transarray[2] FS transarray[3] > OUTPUTFILE" | ||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | </ |