Sponsored Content
Full Discussion: AWK Match to nearest number
Top Forums Shell Programming and Scripting AWK Match to nearest number Post 302513180 by ian_gooch on Wednesday 13th of April 2011 04:33:27 AM
Old 04-13-2011
Thanks aster007,

I will put it to the test tomorrow, and will let you know how I got on.

Many thanks again :-)

Cheers,
Ian

---------- Post updated 04-13-11 at 03:33 AM ---------- Previous update was 04-12-11 at 01:09 PM ----------

Hi aster007

I tottaly missed this up!! :-(

I will try and explain again.......

I have two files lat_lon.txt and node.txt

lat_lon.txt has 1755642 lines in and in collumn 1 has lat numbers and in collumn 2 has lon numbers
eg..
Latitude Longitude 57.14824 -2.09665 57.14871 -2.09781 57.14824 -2.09665 57.14808 -2.09467 57.14843 -2.09797 57.14962 -2.09533 57.14973 -2.09474 57.14867 -2.09599
node.txt has 29648 lines in and in collumn 1 it has a node number and in collumn 2 has lat number and in collumn 3 it has a lon number
eg
1 48.39 -13 2 48.39 -12.89 3 48.39 -12.78 4 48.39 -12.67 5 48.39 -12.56 6 48.39 -12.45 7 48.39 -12.34 8 48.39 -12.23 9 48.39 -12.12 10 48.39 -12.01
Now what I need to do is to cloest match the lon and lat numbers from lon_lat.txt to the lon and lat numbers from node.txt and print the node number is a new file.

I hope this is making sense!

thanks,
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

match nearest

Hi, I'm trying to find the nearest match between two columns of numbers, e.g. 1,1 10,8 30,50 20,100 and the search could be e.g. 20,20 returning 10,8 - i.e. 20-10 = 10 and 20-8 = 12 totalling 22, and hence being the nearest match. any ideas? thanks a lot, (1 Reply)
Discussion started by: bogu0001
1 Replies

2. Shell Programming and Scripting

Rounding off decimals to the nearest number in PERL

Hi Guys, I am generating a statistical report , below is the snippet of the code : Now, $nSlices stands for the time duration,meaning,the statistics will be displayed for that particular time duration. Trouble is, for certain values of $totalTime (which is the end time - start time ), i... (9 Replies)
Discussion started by: rdlover
9 Replies

3. UNIX for Advanced & Expert Users

sed match closest/nearest pattern

All i am struggling to raplace some text in a line between two (closest) patterns , line="/home/usr/bin/:/home/usr/devuser,n1.9/bin:/home/usr/root/bin" i want to replace "devuser,n1.9" with "NEWVAL", basically all teh text from "devuser" until nearest '/' with some new text. i tried teh... (1 Reply)
Discussion started by: sudheer1984
1 Replies

4. Shell Programming and Scripting

Question on awk for finding the column number using a match word

Hi Guys, Please help me out in my situation of writing a shell script Exampl:I have a output like asnapply 1 2 3 apply_server=1 apply_schema=ASN asnapply 1 2 3 apply_server=2 apply_schema=ASN Now i need output like asnacmd applysever=1 applyschema=ASN stop asnacmd applysever=2... (16 Replies)
Discussion started by: mallak
16 Replies

5. UNIX for Dummies Questions & Answers

Rounding up to nearest whole number

Hi all of you, Would be great if you help me with how to round up to whole number from my input values like 2.99996,2.17890,3.00002,-2.3456,-2.7890 o/p should be like 3,2,3,-2,-3 thnks in adv!!!! regards (3 Replies)
Discussion started by: Indra2011
3 Replies

6. Shell Programming and Scripting

Rounding off to the nearest floating number

I have a number, which I want to convert into the nearest floating number upto two places after the decimal point. E.g. 1.2346 will become 1.23 but 1.2356 will become 1.24 . Similarly 0.009 will be 0.01 and 0.001 will be 0.00 or 0.0 (not 0, wnat to keep the decimal... (1 Reply)
Discussion started by: hbar
1 Replies

7. Shell Programming and Scripting

Match pattern and print the line number of occurence using awk

Hi, I have a simple problem but i guess stupid enough to figure it out. i have thousands rows of data. and i need to find match patterns of two columns and print the number of rows. for example: inputfile abd abp 123 abc abc 325 ndc ndc 451 mjk lkj... (3 Replies)
Discussion started by: redse171
3 Replies

8. Shell Programming and Scripting

Selecting nearest pattern match

I'm looking to match an error code against a list of possible codes and get the nearest match. The code would be a 6 character hexadecimal string. I have a file of error codes all of which have a specific first 3 characters, however, after that the last 3 characters may be specific or generic as... (3 Replies)
Discussion started by: dazedandconfuse
3 Replies

9. Shell Programming and Scripting

Match and Grep the nearest value in last field

Gents I have this input file file1 (uniq records) 54503207851 170211240 54503207911 170210837 54503208111 170215105 54503208112 170215210 54655210011 170223140 54655210091 170223738 54655210172 170224355 54655210251 170224741 54655210331 170225039 54655210411 170225505 54655210492... (13 Replies)
Discussion started by: jiam912
13 Replies

10. Shell Programming and Scripting

Checking File record equal to multiple of 70 or nearest number to multiple of 70

Hello, I have a file with below content - Example 3 6 69 139 210 345 395 418 490 492 I would like the result as - Multiple of 70 or nearest number in the file less than the multiple of 70 69 139 (5 Replies)
Discussion started by: Mannu2525
5 Replies
GPS::Point(3pm) 					User Contributed Perl Documentation					   GPS::Point(3pm)

NAME
GPS::Point - Provides an object interface for a GPS point. SYNOPSIS
use GPS::Point; my $obj=GPS::Point->newGPSD($GPSD_O_line);#e.g. GPSD,O=.... my $obj=GPS::Point->new( time => $time, #float seconds from the unix epoch lat => $lat, #signed degrees lon => $lon, #signed degrees alt => $hae, #meters above the WGS-84 ellipsoid speed => $speed, #meters/second (over ground) heading => $heading, #degrees clockwise from North climb => $climb, #meters/second etime => $etime, #float seconds ehorizontal => $ehz, #float meters evertical => $evert, #float meters espeed => $espeed, #meters/second eheading => $ehead, #degrees eclimb => $eclimb, #meters/second mode => $mode, #GPS mode [?=>undef,None=>1,2D=>2,3D=>3] tag => $tag, #Name of the GPS message for data ); DESCRIPTION
This is a re-write of Net::GPSD::Point with a goal of being more re-usable. GPS::Point - Provides an object interface for a GPS fix (e.g. Position, Velocity and Time). Note: Please use Geo::Point, if you want 2D or projection support. USAGE
print scalar($point->latlon), " "; #latlon in scalar context my ($x,$y,$z)=$point->ecef; #if Geo::ECEF is available my $GeoPointObject=$point->GeoPoint; #if Geo::Point is available my @distance=$point->distance($point2); #if Geo::Inverse is available my $distance=$point->distance($point2); #if Geo::Inverse->VERSION >=0.05 USAGE TODO
my $obj=GPS::Point->newNMEA($NMEA_lines); #e.g. GGA+GSA+RMC CONSTRUCTOR
new my $obj = GPS::Point->new(); newGPSD my $obj=GPS::Point->newGPSD($GPSD_O_line);#e.g. GPSD,O=.... newMulti Constructs a GPS::Point from a Multitude of arguments. Arguments can be a GPS::Point, Geo::Point, {lat=>$lat,lon=>$lon} (can be blessed), [$lat, $lon] (can be blessed) or a ($lat, $lon) pair. my $point=GPS::Point->newMulti( $lat, $lon, $alt ); #supports lat, lon and alt my $point=GPS::Point->newMulti([$lat, $lon, $alt]); #supports lat, lon and alt my $point=GPS::Point->newMulti({lat=>$lat, lon=>$lon, ...}); my $point=GPS::Point->newMulti(GPS::Point->new(lat=>$lat, lon=>$lon)); my $point=GPS::Point->newMulti(Geo::Point->new(lat=>$lat, long=>$lon, proj=>'wgs84')); my $point=GPS::Point->newMulti({latitude=>$lat, longtude=>$lon}); Note: Hash reference context supports the following keys lat, lon, alt, latitude, longitude, long, altitude, elevation, hae, elev. Note: Units are always decimal degrees for latitude and longitude and meters above the WGS-84 ellipsoid for altitude. initialize, initializeGPSD, initializeMulti METHODS (Base) time Sets or returns seconds since the Unix epoch, UTC (float, seconds) print $obj->time, " "; lat, latitude Sets or returns Latitude (float, degrees) print $obj->lat, " "; lon, long or longitude Sets or returns Longitude (float, degrees) print $obj->lon, " "; alt, altitude, hae, elevation Sets or returns Altitude (float, meters) print $obj->alt, " "; speed Sets or returns speed (float, meters/sec) print $obj->speed, " "; heading, bearing Sets or returns heading (float, degrees) print $obj->heading, " "; climb Sets or returns vertical velocity (float, meters/sec) print $obj->climb, " "; etime Sets or returns estimated timestamp error (float, seconds, 95% confidence) print $obj->etime, " "; ehorizontal Sets or returns horizontal error estimate (float, meters) print $obj->ehorizontal, " "; evertical Sets or returns vertical error estimate (float, meters) print $obj->evertical, " "; espeed Sets or returns error estimate for speed (float, meters/sec, 95% confidence) print $obj->espeed, " "; eheading Sets or returns error estimate for course (float, degrees, 95% confidence) print $obj->eheading, " "; eclimb Sets or returns Estimated error for climb/sink (float, meters/sec, 95% confidence) print $obj->eclimb, " "; mode Sets or returns the NMEA mode (integer; undef=>no mode value yet seen, 1=>no fix, 2=>2D, 3=>3D) print $obj->mode, " "; tag Sets or returns a tag identifying the last sentence received. For NMEA devices this is just the NMEA sentence name; the talker-ID portion may be useful for distinguishing among results produced by different NMEA talkers in the same wire. (string) print $obj->tag, " "; METHODS (Value Added) fix Returns either 1 or 0 based upon if the GPS point is from a valid fix or not. print $obj->fix, " "; At a minimum this method requires mode to be set. datetime Returns a DateTime object from time my $dt=$point->datetime; At a minimum this method requires time to be set. latlon, latlong Returns Latitude, Longitude as an array in array context and as a space joined string in scalar context my @latlon=$point->latlon; my $latlon=$point->latlon; At a minimum this method requires lat and lon to be set. setAltitude Sets altitude from USGS web service and then returns the GPS::Point object. This method is a wrapper around Geo::WebService::Elevation::USGS. my $point=GPS::Point->new(lat=>$lat, lon=>$lon)->setAltitude; $point->setAltitude; my $alt=$point->alt; At a minimum this method requires lat and lon to be set and alt to be undef. ecef Returns ECEF coordinates. This method is a warpper around Geo::ECEF. my ($x,$y,$z) = $point->ecef; my @xyz = $point->ecef; my $xyz_aref = $point->ecef; #if Geo::ECEF->VERSION >= 0.08 At a minimum this method requires lat and lon to be set. (alt of 0 is assumed by Geo::ECEF->ecef). GeoPoint Returns a Geo::Point Object in the WGS-84 projection. my $GeoPointObject = $point->GeoPoint; At a minimum this method requires lat and lon to be set. distance Returns distance in meters between the object point and the argument point. The argument can be any valid argument of newMulti constructor. This method is a wrapper around Geo::Inverse. my ($faz, $baz, $dist) = $point->distance($pt2); #Array context my $dist = $point->distance($lat, $lon); #if Geo::Inverse->VERSION >=0.05 At a minimum this method requires lat and lon to be set. track Returns a point object at the predicted location in time seconds assuming constant velocity. Using Geo::Forward calculation. my $new_point=$point->track($seconds); #default $point->heading my $new_point=$point->track($seconds => $heading); At a minimum this method requires lat and lon to be set. It might be very useful to have speed, heading and time set although they all default to zero. forward Returns a point object at the distance and heading using Geo::Forward calculations. my $point=$point->forward($dist); #default $point->heading my $point=$point->forward($dist => $heading); #meters => degrees At a minimum this method requires lat and lon to be set. It might be useful to have heading set although the default is zero. BUGS
Send to GPSD-DEV or GEO-PERL email lists SUPPORT
Try GPSD-DEV or GEO-PERL email lists AUTHOR
Michael R. Davis CPAN ID: MRDVT DavisNetworks.com account=>perl,tld=>com,domain=>michaelrdavis http://www.davisnetworks.com/ COPYRIGHT
This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. SEE ALSO
Geo::Point, Net::GPSD, Net::GPSD::Point, Geo::ECEF, Geo::Functions, Geo::Forward, Geo::Inverse, Geo::Distance, Geo::Ellipsoids, Geo::WebService::Elevation::USGS, DateTime perl v5.10.1 2010-01-30 GPS::Point(3pm)
All times are GMT -4. The time now is 06:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy