Your SlideShare is downloading. ×
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Geographic Computation in Perl
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Geographic Computation in Perl

154

Published on

Computations involving geographic coordinates are commonplace today with maps and location-based services. There are many modules on CPAN which can help Perl programmers to do these computations more …

Computations involving geographic coordinates are commonplace today with maps and location-based services. There are many modules on CPAN which can help Perl programmers to do these computations more easily. Examples are provided where Perl was used to generate the search grid for a missing rocket payload on a large dry lakebed in Nevada, and for mapping progress of a high-altitude balloon over Central California and the teams who were chasing it.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
154
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Geographic Computation in Perl Presented by Ian Kluft Silicon Valley Perl March 3, 2011 Santa Clara, CaliforniaPresented at SVPerl Geographic Computation in Perl Slide 1 of 23March 3, 2011 By Ian Kluft
  • 2. Safety warning If you think the world is flat, this presentation will make your head explode.Presented at SVPerl Geographic Computation in Perl Slide 2 of 23March 3, 2011 By Ian Kluft
  • 3. Geography is BIG Today ● Maps on paper go back to ancient times ● Electronic age: natural move to web and mobile ● Geography is a deeper subject than just maps ● Any data pertaining to Earths surface ● Processing GPS data ● Computing Great Circle routes ● Geographic Information Systems (GIS) ● Location Based Services (LBS)Presented at SVPerl Geographic Computation in Perl Slide 3 of 23March 3, 2011 By Ian Kluft
  • 4. Geospatial location data ● Locations on Earth can be specified by ● Latitude – angle north/south from equator to poles ● Longitude – angle east/west from Prime Meridian ● Altitude – height above/below mean sea level ● Altitude is omitted when using surface elevation ● Latitude and longitude are angles measured from the center of the Earth ● Geographic data is more correctly called geospatial data when broken down in this formPresented at SVPerl Geographic Computation in Perl Slide 4 of 23March 3, 2011 By Ian Kluft
  • 5. Earth is not a perfect sphere ● Earth is an ellipsoid: bulges out at equator ● Centrifugal force from rotation causes this ● Geoid: mathematical models for Earth ellipsoid ● Good models come from satellite measurement ● Coordinates must use the same geographic reference system ● Otherwise comparing apples and oranges ● WGS84 most widely used coordinate system todayPresented at SVPerl Geographic Computation in Perl Slide 5 of 23March 3, 2011 By Ian Kluft
  • 6. Sources of Geospatial Data ● Data can be gathered by many sources ● Measured by professional surveyors ● Measured by satellite (remote sensing) ● Measured by professionals or amateurs by GPS ● Read from maps ● Geocoded from street addresses ● Computations relative to other dataPresented at SVPerl Geographic Computation in Perl Slide 6 of 23March 3, 2011 By Ian Kluft
  • 7. Lots of angles in Geospatial Data ● This may come as bad news ● There really was a use for that Trigonometry stuff some of you hated in school ● Many computations involve angles ● Latitude and longitude are angles ● Manipulations use trigonometric functions ● Useful to brush up on Trig to know what its doing ● Trig functions use radians ● So numbers in degrees must be converted firstPresented at SVPerl Geographic Computation in Perl Slide 7 of 23March 3, 2011 By Ian Kluft
  • 8. Get Math::Trig Module from CPAN ● CPAN has many Perl modules to help with Trigonometry and Geospatial calculations ● Math::Trig has the basic foundation ● deg2rad() - convert degrees to radians ● rad2deg() - convert radians to degrees ● All the basic Trig functions ● A bonus: basic Great Circle calculations too ● http://search.cpan.org/search?query=Math%3A%3ATrigPresented at SVPerl Geographic Computation in Perl Slide 8 of 23March 3, 2011 By Ian Kluft
  • 9. Great Circle Routes ● Great Circle: direct route over Earths surface ● Along a line that would go around the sphere ● i.e. from San Jose to London crosses Greenland Map generated by the Great Circle Mapper - copyright © Karl L. Swartz. http://www.gcmap.com/Presented at SVPerl Geographic Computation in Perl Slide 9 of 23March 3, 2011 By Ian Kluft
  • 10. Great Circle Computations ● Useful for mapping and navigation ● Distance between any two points on Earth ● Initial course from one point to another ● Points along the path between two points ● Intersection of courses/lines/radials ● Projecting a point at distance/bearing from a point ● Even over small distances, they can still be computed as angles from center of the EarthPresented at SVPerl Geographic Computation in Perl Slide 10 of 23March 3, 2011 By Ian Kluft
  • 11. Great Circle Tools and Info ● Many formulas at Aviation Formulary site ● by Ed Williams ● http://williams.best.vwh.net/avform.htm ● Great Circle online mapping tool ● by Karl Swartz ● http://gcmap.com/ ● OReillys “Mapping Hacks” book ● by Erle, Gibson and WalshPresented at SVPerl Geographic Computation in Perl Slide 11 of 23March 3, 2011 By Ian Kluft
  • 12. Geospatial-related Perl Modules ● Perl modules with Great Circle functions ● Geo::Calc ● Geo::Track::Log ● GIS::Distance ● Perl module front-ends to mapping sites ● Geo::Google::StaticMaps – Google Maps ● Geo::OSM::StaticMaps – OpenStreetMap ● Many more – use search.cpan.org to searchPresented at SVPerl Geographic Computation in Perl Slide 12 of 23March 3, 2011 By Ian Kluft
  • 13. ExamplesTwo examples follow with Perl code that wasactually used for geographic computation to solvereal problems. ● CanSat Search at Black Rock Desert Perl script generated search area coordinates for a missing payload from a rocket launch ● Balloon and tracking teams live APRS map Perl script makes live tracking map of teams chasing a high-altitude balloonPresented at SVPerl Geographic Computation in Perl Slide 13 of 23March 3, 2011 By Ian Kluft
  • 14. Example 1 CanSat Search at Black Rock DesertLocation: Black Rock Desert, NevadaProblem: Rocket launched, payload missing ● Soka University (Japan) students needed data ● AeroPac club knew rocket landing coordinates ● Turned to Stratofox Aerospace Tracking Team ● Transmitter batteries died before their contact ● I wrote a Perl script to generate a grid searchPresented at SVPerl Geographic Computation in Perl Slide 14 of 23March 3, 2011 By Ian Kluft
  • 15. Perl Script to Plot Search Grid ● Search area was 3x3 mile parallelogram ● Each side divided into 10 sections, 1584 long ● 10x10 loop projects each computed waypoint ● Command-line controls output to text or GPX ● “gpsbabel” turns GPX into many formats ● Raw Garmin waypoint data for upload to GPS ● KML for display on Google EarthPresented at SVPerl Geographic Computation in Perl Slide 15 of 23March 3, 2011 By Ian Kluft
  • 16. Projecting Search Grid Waypoints ● Nested loop: i = 0-10 over, j = 0-10 up ● Over = 270° heading, up = 330° heading ● Convert lat/lon from degrees to radians ● Use Great Circle projection formula ● Compute intermediate point from i “over” ● Compute final point from j “up” ● Convert new lat/lon from radians to degrees ● Code available at svperl.org with slidesPresented at SVPerl Geographic Computation in Perl Slide 16 of 23March 3, 2011 By Ian Kluft
  • 17. Search Area Grid MapResult of the script shown on Google EarthPresented at SVPerl Geographic Computation in Perl Slide 17 of 23March 3, 2011 By Ian Kluft
  • 18. Result: Success!!!Expected to be worse than needle in a haystackPayload found 2500 west of rocket landing sitePresented at SVPerl Geographic Computation in Perl Slide 18 of 23March 3, 2011 By Ian Kluft
  • 19. Example 2 Live APRS Balloon Tracking MapProblem: Display APRS tracking data for aballoon and our team who are tracking it ● APRS = Automatic Packet Reporting System, Ham Radio data protocol for transmitting your position ● The balloon and the tracking team all transmit their positions via APRS every minute or so ● Sites to display APRS data on a map dont do what we wantPresented at SVPerl Geographic Computation in Perl Slide 19 of 23March 3, 2011 By Ian Kluft
  • 20. APRS.FI posted their Perl code ● Popular APRS mapping site APRS.FI uses Perl ● They posted Ham::APRS::FAP (“fabulous APRS parser”) on CPAN for all Perl developers ● You need Ham Radio license to transmit APRS ● You do not need Ham Radio license to receive APRS data ● Many volunteers forward APRS packets to APRS-IS servers on the Internet ● Everyone can subscribe to data streams therePresented at SVPerl Geographic Computation in Perl Slide 20 of 23March 3, 2011 By Ian Kluft
  • 21. Custom APRS Mapping Script ● Command-line parameter sets callsigns to log ● Subscribe to APRS-IS via Ham::APRS::FAP ● For each incoming line: ● Parse line w/ Ham::APRS::FAP ● Save data in a per-callsign list ● Update output file in GeoRSS format ● Output file URL can be used in near real-time as an input to Google Maps ● Code available at svperl.org with slidesPresented at SVPerl Geographic Computation in Perl Slide 21 of 23March 3, 2011 By Ian Kluft
  • 22. Balloon Chase on Google Maps ● A balloon on Feb 5, 2011 was lost in the ocean ● Teams chased it until Carmel – others watchedPresented at SVPerl Geographic Computation in Perl Slide 22 of 23March 3, 2011 By Ian Kluft
  • 23. What else can you do? ● Your imagination may be your only limit ● Get a Google Maps API key and you can embed Google Maps into your web pages ● Calculate air-mile distance of a trip you took ● Process satellite data downloaded from NASA ● What do you want to do? ● Post your new modules on CPAN!Presented at SVPerl Geographic Computation in Perl Slide 23 of 23March 3, 2011 By Ian Kluft

×