Sponsored Content
Top Forums Shell Programming and Scripting Linear Interpolation of CSV Columnar Data Post 303038319 by hrrruser on Friday 30th of August 2019 09:53:44 AM
Old 08-30-2019
Thank you! This is exactly what I was looking for.

Quote:
Originally Posted by rdrtx1
try:
Code:
awk -F, '
   function interpolate(lat1, lon1, t1, lat2, lon2, t2, p) {
       for (i = 1; i <= (t2 - t1); i++) {
           printf "%.2f,%.2f,%.1f\n",
              lat1 + (t2 - t1) * (lat2 - lat1) / p,
              lon1 + (t2 - t1) * (lon2 - lon1) / p,
              t1 + i * (t2 - t1) / p
       }
   }
   NR >= 2 {interpolate(lat, lon, t, $1, $2, $3, ++p); p=0;}
   {lat = $1; lon = $2; t = $3; ++p}
   {print}
' file.in.csv > file.out.csv

 

10 More Discussions You Might Find Interesting

1. Programming

LInear Addresses

Hi all, Even after reading many explanation the question still haunting me what's the difference between physical and linear addresses.Can we directly access physical addresses .If not then paging circuitry would have ensure contiguous physical addresses regardless of any linear addresses but this... (2 Replies)
Discussion started by: joshighanshyam
2 Replies

2. Shell Programming and Scripting

Converting to columnar output

Hi All, I need some help in script or awk to create a textfile. I have a directory where two subdirectories exists say A and B. Now I need to write a ".txt" file with well arranged(space wraped) three columns in it with the data as follows: 1st column:Serial number(which will increment... (4 Replies)
Discussion started by: Sreejith_VK
4 Replies

3. Shell Programming and Scripting

Linear data to column data..script help seeked

Hello Take a look at following lines. This is giving me an o/p all in one array where as i want the column to be printed.How can i do it? e.g I am getting: 1575028616...... whereas i want 1 5750 28616 I am writing this small piece and trying to get this column o/p in a CSV. ... (1 Reply)
Discussion started by: ak835
1 Replies

4. Shell Programming and Scripting

Formatting Data - CSV

I want to check whether if any column data has any + , - , = prefixed to it then convert it in such a form that in excel its not read as formula. echo "$DATA" | awk 'BEGIN { OFS="," } -F" " {print $1,$2,$3,$4,$5,$6,$7,$8.$9,$10,$11,$12}' (4 Replies)
Discussion started by: dinjo_jo
4 Replies

5. Shell Programming and Scripting

File Comparison Columnar?

I'm looking to build up a process which would compare 2 files and show difference, the difference needs to be done in such a way that it also shows which column value is differing. So i think of this. Run a diff between the files , then someway find which columns have different values need to... (6 Replies)
Discussion started by: dinjo_jo
6 Replies

6. Programming

Linear hashing implementation in C language

Hi, I'm looking for linear hashing implementation in C language. Please help. PS: I have implement this on Ubuntu 10.04 Linux on 64 bit machine. (1 Reply)
Discussion started by: sajjar
1 Replies

7. Shell Programming and Scripting

Converting variable space width data into CSV data in bash

Hi All, I was wondering how I can convert each line in an input file where fields are separated by variable width spaces into a CSV file. Below is the scenario what I am looking for. My Input data in inputfile.txt 19 15657 15685 Sr2dReader 107.88 105.51... (4 Replies)
Discussion started by: vharsha
4 Replies

8. Programming

Find gaps in time data and replace missing time value and column 2 value by interpolation in awk

Dear all, I am kindly seeking assistance on the following issue. I am working with data that is sampled every 0.05 hours (that is 3 minutes intervals) here is a sample data from the file 5.00000 15.5030 5.05000 15.6680 5.10000 16.0100 5.15000 16.3450 5.20000 16.7120 5.25000... (4 Replies)
Discussion started by: malandisa
4 Replies

9. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

10. Programming

Joining Columnar heading from 2 lines

Hi, Below is the format of a report generated by a custom reporting solution. I opened the report in Notepad++ and junked data and values as in the image below. https://www.unix.com/attachment.php?attachmentid=7907&stc=1&d=1575507708 I want to convert the values to a PIPE delimited format as... (2 Replies)
Discussion started by: ramkrix
2 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:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy