hiii, Help me out..i have a huge set of data stored in a file.This file has has 2 columns which is latitude & longitude of a region. Now i have a program which asks for the number of points & based on this number it asks the user to enter that latitude & longitude values which are in the same region.here first point & last point should have same latitude & longitude so as to form a polygon. I mean to say this points form a polygon on the entire region of the data given in file.
Now i want a program using awk or unix which takes data from this file & points entered from user & then comparing this , it takes data from the file & stores data in another file such that for data which is only in the region of points or for data which is inside the polygon.
In short i want program which stores the data in another file only polygon region's data not the entire region of the file.
Please please Help me out.
For exampl:
Few lines of the file data are as follows
a.dat:
HTML Code:
BDA 1908 8 20 9 53 0.00 32.0000N 89.0000E 60.0 0 0.00 0 0.00 0.00 6.60 0 7.00 7.00 0 NULL
BDA 1915 12 3 2 39 19.00 29.5000N 91.5000E 60.0 0 0.00 0 0.00 0.00 6.70 0 7.10 7.10 0 NULL
SIG 1927 5 22 0 0 0.00 36.0000N 96.0000E 0.0 0 0.00 0 0.00 0.00 7.50 0 8.00 8.00 0 NULL
BDA 1934 12 15 1 57 37.00 31.3000N 89.3000E 60.0 0 0.00 0 0.00 0.00 6.70 0 7.10 7.10 0 NULL
SIG 1937 1 7 0 0 0.00 35.5000N 98.0000E 0.0 0 0.00 0 0.00 0.00 7.10 0 7.60 7.60 0 NULL
LEE 1937 1 7 13 20 41.00 35.5000N 97.6000E 0.0 0 0.00 0 0.00 0.00 7.10 0 7.60 7.60 10 NULL
SIG 1947 7 29 0 0 0.00 28.5000N 94.0000E 60.0 0 0.00 0 0.00 0.00 7.30 0 7.80 7.80 0 NULL
BDA 1947 7 29 13 43 22.00 28.5000N 94.0000E 60.0 0 0.00 0 0.00 0.00 7.40 0 7.90 7.90 0 NULL
G-R 1950 8 15 14 9 30.00 28.5000N 96.5000E 25.0 0 0.00 0 0.00 0.00 8.10 0 8.70 8.70 10 NULL
ISS 1950 9 13 11 7 27.00 27.5000N 96.4000E 0.0 0 0.00 0 0.00 0.00 6.60 0 7.00 7.00 7 NULL
G-R 1951 11 18 9 35 47.00 30.5000N 91.0000E 25.0 0 0.00 0 0.00 0.00 7.40 0 7.90 7.90 4 NULL
LEE 1951 11 18 9 35 50.00 31.1000N 91.4000E 0.0 0 0.00 0 0.00 0.00 7.50 0 8.00 8.00 0 NULL
G-R 1952 8 17 16 2 7.00 30.5000N 91.5000E 0.0 0 0.00 0 0.00 0.00 7.00 0 7.50 7.50 9 NULL
BDA 1963 4 19 7 35 24.00 35.8000N 96.9000E 33.0 0 0.00 0 0.00 0.00 6.60 0 7.00 7.00 0 NULL
PDE 2001 11 14 9 26 10.01 35.9500N 90.5400E 10.0 0 0.00 0 0.00 7.80 8.30 0 0.00 8.30 0 NULL
Here the 8 & 9th column is latitude & longitude of a region.
Using small program what i have it asks for
Enter no of points as : 7
Then for this 7 points the user will enter latitude & longitude using for loop. this 7 points i am entering is for ex:.
HTML Code:
29.45, 89.43
32.47, 90.98
27.25, 95.63
27.29, 98.27
36.74, 96.32
31.90, 87.67
29.45, 89.43
Actu this points forms a plygon in the given region of the file.. Now i want a program in such way that the points or the latitude & longitude only inside the polygon should be stored in another file say b.dat.
The answer for the above example or the output file using above file a.dat & the points
are
b.dat:
HTML Code:
BDA 1908 8 20 9 53 0.00 32.0000N 89.0000E 60.0 0 0.00 0 0.00 0.00 6.60 0 7.00 7.00 0 NULL
SIG 1927 5 22 0 0 0.00 36.0000N 96.0000E 0.0 0 0.00 0 0.00 0.00 7.50 0 8.00 8.00 0 NULL
BDA 1934 12 15 1 57 37.00 31.3000N 89.3000E 60.0 0 0.00 0 0.00 0.00 6.70 0 7.10 7.10 0 NULL
G-R 1950 8 15 14 9 30.00 28.5000N 96.5000E 25.0 0 0.00 0 0.00 0.00 8.10 0 8.70 8.70 10 NULL
ISS 1950 9 13 11 7 27.00 27.5000N 96.4000E 0.0 0 0.00 0 0.00 0.00 6.60 0 7.00 7.00 7 NULL
Now please me out.
Actu i have a region full of data i.e from latitude 0 to 40 & longitude 60 to 100.
Now i am asking for few points & based on how many ever points i am entering the lat & long for those points, this x,y points or lat long form a closed loop or polygon inside the given region 0 to 40 & 60 to 100..Now what i need is only the data which is inside that polygon or points which form a loop..Please help me out with a simple program..