Pulling data by GPS coordinates from text file

Hi there,
I'm having a problem trying to extract data from within a text file. I'm trying to extract this manually for a lack of better words.
I need any items that fall within latitude 36.5 to 39.5 and long -75.3 to -83.9

I have been doing this using cat neta.txt | grep '!38' and working this slowly. I know there is an easier way. I'm drawing a blank.

Thanks you in advance for any help.

Mike

Here is an example from the text file.

KB0JBF-3>APN382,qAS,KB0JBF:!4229.36NL09332.63W#PHG6130/R,IAN,WIDEN 444.500 PL151.4 WILLIAMS,IA
LD4ST>APNU19,qAR,LA6JF-2:!5902.71NS00559.07E#PHG3500 STRAND W3,NORn
KA0GFC-3>APW284,TCPIP*,qAC,FIRST:=3856.83NS09244.75W#PHG9250/KA0GFC BOONVILLE ECHOLINK#239712 -MOBOOCOLUMBIA-284-<630>
W4LJM>APN383,KF4OWQ-2*,WIDE3-2,qAR,KF4REN:!3729.00NS08541.48W#PGH7450 W2, Kyn-N Digi in Buffalo, Ky.
VE7RKA>APN382,qAR,VE7RXD-9:!5036.65NS12038.00W#PHG4840/W2,BCn,Greenstone Mtn VE7FSR
KD8KSN-1>APN391,K8QIK-5*,WIDE1,WIDE2-2,qAR,K8PJ-1:!4009.87N/08229.17W#PHG5370/W3,OHn-n kd8ksn@amsat.org
I0TVL-11>APNU19,WIDE3-2,qAR,IR0UFQ-2:!4153.07N/01228.98E#PHG3160/DIGI APRS I0TVL -Roma Centro- Sito di I0TVL Giuseppe
NR6G-3>APN391,qAR,NR6G-1:!3620.90NS12036.03W#PHG3930 WIDEn-N, NCAn-N Weather Station Digi on Santa Rita PK
KF4OWQ-2>APN391,WIDE2-2,qAR,KF4REN:!3709.02N/08359.28W# LONDON KY
F6DBP-3>APFD33,F6KLI-4,WIDE1*,WIDE3-3,qAR,F6KLI-15:@000000h4457.06N/00018.66W#PHG3560 Digi solaire en test 
S55YZA-11>APNU19,WIDE3-3,qAo,S56UBS-11:!4611.22N/01506.45E#PHG3030/(2: S55YZA INFO:s57c@hamradio.si)
K9ABC-1>APN383,qAR,W9RCG-1:!4304.39NS08823.26W#PHG7760/W3,WIn Welcome to the Frontpage
SR4NWH>APU25N,TCPIP*,qAC,T2POLAND:=5310.36NS02202.34E#PHG3370 Lomza IGATE henpor@interia.pl
KB2JOE-15>APU25N,TCPIP*,qAC,T2MSSOURI:=4051.47N/07311.49W#SMITHTOWN ARES DIV4
F4FXL-3>APRX22,WIDE2-2,qAR,DB0MOE:!4849.51N100736.42E#Digi Val de Moder, serving the community since 2010
XE1SDK>APN382,WIDE2-1,qAR,XE1KK:!1903.56NF09810.44W#PHG22304/DIGI EN PUEBLA, GRID EK09
ZL2BAU>APX200,TCPIP*,qAC,T2NZAA:;GOR      *101829z4602.24SP16851.36E# ZL4AL-1 TheNet2.08 Netrom Digi 144.650 MHz
K1LH-3>APN391,WIDE2-1,qAR,KG4MFJ-1:!3604.92NS08522.45W#PHG5450/ Serving the Upper Cumberland.
KC0MWM-1>APOT2A,WIDE2-2,qAR,N0YXV-1:!4055.45NS09820.35W#PHG8330   EOC Digi
LD4SJ>APNU19,qAS,LA4JAA:!5852.08NS00540.80E#PHG3230 SANDNES   W3,NORn
VE3KCR>APN383,qAo,SFLDV:!4226.14NS08206.23W#PHG7640/W2,SONTn,Chatham - ve3cih@rac.ca
AA8KY-10>APNU19,WIDE3-3,qAS,AA8KY:!3844.13NS08300.00W# W3 OHn Portsmouth, OH
LAMAR>APN382,qAR,KC0HH:!3802.22NS10235.97W#PHG5550 W2, COn-N, KC0HH LAMAR,CO
CT1FNE-3>APNU3B,CQ0XCM-3,CT0XOD-3*,qAR,CT1EJC-3,PORTUGAL:!3832.05NS00852.73W#PHG3330 W3,PRTn Setubal
KI4WEF>APN391,K4KJQ-10,WIDE1*,WIDE2-1,qAo,KD4SN:!3831.35N108434.13W#PHG5030/W1,KY1 FILL-IN DIGI
WB0HAC>APN391,qAR,K0SUN-10:!3859.33NS09450.66W#PHG5591/W3 KCMOn SRACT in Shawnee KS wb0hac@kc.rr.com
IK8TGH-11>APNU19,qAR,IW8RBI-1:!3812.71N/01538.29E# (DIGI Villa San Giovanni JM78TF)
J41VAF>APZ186,J41VAI*,qAR,SV1UY-10:!3802.99N/02352.17E#PHG4880/  grcNet  * S.R.E. *DataGroup* 
KV3B-2>APN383,qAR,K7BC:!3857.05NS07652.41W#PHG5560 Montgomery ARC
KC0IRJ-3>APN383,qAR,KB0PJH:!3833.12NL09212.79W#PHG5320 KC0IRJ-3 W3,MOn
IW8QPG-11>APZ186,TRACE7-7,qAR,IT9ITT:!3812.43N/01545.14E#PHG5460/IK8TGH Email antoniotgh@alice.it
KA0GFC-4>APN391,qAS,KA0GFC-3:!3815.21N109155.76W#PHG7250 W1,MOn 443.700 77.0 FREEBURG, MO
IQ8LD>APNU19,IR8AM,IW9CRG-11*,qAR,IT9ITT:!3822.12N/01624.04E# (A.R.I.Locride prov.Reggio Cal.APRS) 1
IR9BB>APNU19,WIDE,qAR,IW8RBI-1:!3808.13N/01529.12E# (Cisar MESSINA)
KC4WCG-3>APN382,qAR,K0SUN-10:!3846.91NS09445.63W# W3 KSn-N SUNROSES kc4wcg@hotmail.com
ZL1BCO-3>APNU3B,WIDE1-1,qAR,ZL1SY-1:!3831.11S/17601.29E#PHG4852 UIDIGI V1.9, b3 - Mt. Maroanui - Taupo
KI4WEF>APN391,K4KJQ-10,WIDE1*,WIDE2-1,qAo,KD4SN:!3831.35N108434.13W#PHG5030/W1,KY1 FILL-IN DIGI
CU3URA-1>APOT21,WIDE1-1,WIDE2-2,qAR,CU3CO,PORTUGAL:!3843.80N/02719.07W#13.6V  13C *DIGI*CU3URA*STA BARBARA*TERCEIRA*AZORES ISL.*

Please explain a sample line -

KB0JBF-3>APN382,qAS,KB0JBF:!4229.36NL09332.63W#PHG6130/R,IAN,WIDEN 444.500 PL151.4 WILLIAMS,IA

I see
4229.36N
09332.63W

Yes you are correct ! beginning marker
4229.36N is the lat 42 29.36N
L ignore this space
09332.63W is the lon 093 32.63W

In your text you said you were grabbing for !38
But, not all lines (like 3rd) does not follow that logic.

See following:

$ awk -F'!' '{long=substr($2,1,4); lat=substr($2,10,5); print long"--"lat}' <sample2.txt
4229--09332
5902--00559
--
3729--08541
5036--12038
4009--08229
4153--01228
3620--12036
3709--08359
--
4611--01506

I copied first several lines of your file to experiment with. But a couple lines do not follow pattern.

The example was yes a grep of !38 Then I did a grep of !39 and so fourth. Every time I update the file I have to re run my sequence all over again.

What about your 3rd line?

grep '!38'

will not capture, but would appear to be valid.

Lines like 3rd and 10th are to be ignored?

I will have to go back and visit those items. I was looking through the database and found these preceding the coords :
! and = anything else appears to be bad data because of poor data entry at the end point. I'm not interested in that.

---------- Post updated at 05:21 PM ---------- Previous update was at 04:08 PM ----------

<code>
awk -F'!' '{lat=substr($2,1,2); lon=substr($2,10,3); (lat >36 && lat <39) && (lon > -75 && lon < -84) print lat"--"lon}' < net.log
</code>
The above code is what I have tried without success.

The only two valid items ahead of the lat is either ! or = nothing else.