Spatial Data Processing

Intro paragraph

  • deterministic spatial analysis (SG)

  • Explain what we mean by dsa

  • outline what we will cover below

airports.csv

Vignette: Airports

  • Querying based on attributes (volume, lon/lat, etc.)
import pandas as pd
import geopandas as gpd
df = pd.read_csv("../data/airports/world-airports.csv")
df.head()
id ident type name latitude_deg longitude_deg elevation_ft continent iso_country iso_region municipality scheduled_service gps_code iata_code local_code home_link wikipedia_link keywords score last_updated
0 2434 EGLL large_airport London Heathrow Airport 51.470600 -0.461941 83.0 EU GB GB-ENG London 1 EGLL LHR NaN http://www.heathrowairport.com/ http://en.wikipedia.org/wiki/London_Heathrow_A... LON, Londres 1251675 2016-02-09T10:54:31+00:00
1 3632 KLAX large_airport Los Angeles International Airport 33.942501 -118.407997 125.0 NaN US US-CA Los Angeles 1 KLAX LAX LAX http://www.iflylax.com/ http://en.wikipedia.org/wiki/Los_Angeles_Inter... NaN 1335475 2010-01-23T11:27:55+00:00
2 3754 KORD large_airport Chicago O'Hare International Airport 41.978600 -87.904800 672.0 NaN US US-IL Chicago 1 KORD ORD ORD http://www.flychicago.com/ohare/en/home/Pages/... http://en.wikipedia.org/wiki/O'Hare_Internatio... CHI, Orchard Place 1503175 2014-08-19T18:55:27+00:00
3 3622 KJFK large_airport John F Kennedy International Airport 40.639801 -73.778900 13.0 NaN US US-NY New York 1 KJFK JFK JFK http://www.panynj.gov/CommutingTravel/airports... http://en.wikipedia.org/wiki/John_F._Kennedy_I... Manhattan, New York City, NYC, Idlewild 1052075 2010-01-23T11:27:54+00:00
4 3384 KATL large_airport Hartsfield Jackson Atlanta International Airport 33.636700 -84.428101 1026.0 NaN US US-GA Atlanta 1 KATL ATL ATL http://www.atlanta-airport.com/ http://en.wikipedia.org/wiki/Hartsfield-Jackso... NaN 2002475 2008-06-13T14:30:04+00:00

Let's use pandas to query for the airports within the large_airport class:

df[df.type == 'large_airport']
id ident type name latitude_deg longitude_deg elevation_ft continent iso_country iso_region municipality scheduled_service gps_code iata_code local_code home_link wikipedia_link keywords score last_updated
0 2434 EGLL large_airport London Heathrow Airport 51.470600 -0.461941 83.0 EU GB GB-ENG London 1 EGLL LHR NaN http://www.heathrowairport.com/ http://en.wikipedia.org/wiki/London_Heathrow_A... LON, Londres 1251675 2016-02-09T10:54:31+00:00
1 3632 KLAX large_airport Los Angeles International Airport 33.942501 -118.407997 125.0 NaN US US-CA Los Angeles 1 KLAX LAX LAX http://www.iflylax.com/ http://en.wikipedia.org/wiki/Los_Angeles_Inter... NaN 1335475 2010-01-23T11:27:55+00:00
2 3754 KORD large_airport Chicago O'Hare International Airport 41.978600 -87.904800 672.0 NaN US US-IL Chicago 1 KORD ORD ORD http://www.flychicago.com/ohare/en/home/Pages/... http://en.wikipedia.org/wiki/O'Hare_Internatio... CHI, Orchard Place 1503175 2014-08-19T18:55:27+00:00
3 3622 KJFK large_airport John F Kennedy International Airport 40.639801 -73.778900 13.0 NaN US US-NY New York 1 KJFK JFK JFK http://www.panynj.gov/CommutingTravel/airports... http://en.wikipedia.org/wiki/John_F._Kennedy_I... Manhattan, New York City, NYC, Idlewild 1052075 2010-01-23T11:27:54+00:00
4 3384 KATL large_airport Hartsfield Jackson Atlanta International Airport 33.636700 -84.428101 1026.0 NaN US US-GA Atlanta 1 KATL ATL ATL http://www.atlanta-airport.com/ http://en.wikipedia.org/wiki/Hartsfield-Jackso... NaN 2002475 2008-06-13T14:30:04+00:00
5 4185 LFPG large_airport Charles de Gaulle International Airport 49.012798 2.550000 392.0 EU FR FR-J Paris 1 LFPG CDG NaN http://www.aeroportsdeparis.fr/ http://en.wikipedia.org/wiki/Charles_de_Gaulle... PAR, Aéroport Roissy-Charles de Gaulle, Roissy... 1127475 2010-01-05T18:17:43+00:00
6 3878 KSFO large_airport San Francisco International Airport 37.618999 -122.375000 13.0 NaN US US-CA San Francisco 1 KSFO SFO SFO http://www.flysfo.com/ http://en.wikipedia.org/wiki/San_Francisco_Int... QSF, QBA 1112475 2008-06-13T14:30:04+00:00
7 2513 EHAM large_airport Amsterdam Airport Schiphol 52.308601 4.763890 -11.0 EU NL NL-NH Amsterdam 1 EHAM AMS NaN http://www.schiphol.nl/ http://en.wikipedia.org/wiki/Amsterdam_Schipho... NaN 1093275 2011-10-05T23:26:15+00:00
8 2212 EDDF large_airport Frankfurt am Main International Airport 50.033333 8.570556 364.0 EU DE DE-HE Frankfurt-am-Main 1 EDDF FRA NaN http://www.frankfurt-airport.de/ http://en.wikipedia.org/wiki/Frankfurt_Airport EDAF, Rhein-Main Air Base 1144675 2016-09-15T03:34:21+00:00
9 3521 KEWR large_airport Newark Liberty International Airport 40.692501 -74.168701 18.0 NaN US US-NJ Newark 1 KEWR EWR EWR http://www.panynj.gov/CommutingTravel/airports... http://en.wikipedia.org/wiki/Newark_Liberty_In... Manhattan, New York City, NYC 1064475 2008-06-13T14:30:04+00:00
10 3631 KLAS large_airport McCarran International Airport 36.080101 -115.152000 2181.0 NaN US US-NV Las Vegas 1 KLAS LAS LAS http://www.mccarran.com/ http://en.wikipedia.org/wiki/McCarran_Internat... NaN 1068475 2010-07-05T16:48:39+00:00
11 3488 KDFW large_airport Dallas Fort Worth International Airport 32.896801 -97.038002 607.0 NaN US US-TX Dallas-Fort Worth 1 KDFW DFW DFW http://www.dfwairport.com/ http://en.wikipedia.org/wiki/Dallas-Fort_Worth... QDF 1203175 2008-06-13T14:30:04+00:00
12 3670 KMCO large_airport Orlando International Airport 28.429399 -81.308998 96.0 NaN US US-FL Orlando 1 KMCO MCO MCO http://www.orlandoairports.net/ http://en.wikipedia.org/wiki/Orlando_Internati... Disney World,Epcot Center 1044075 2008-06-13T14:30:04+00:00
13 3486 KDEN large_airport Denver International Airport 39.861698 -104.672997 5431.0 NaN US US-CO Denver 1 KDEN DEN DEN http://www.flydenver.com/ http://en.wikipedia.org/wiki/Denver_Internatio... DVX, KVDX 1103275 2015-11-13T09:28:42+00:00
14 3685 KMIA large_airport Miami International Airport 25.793200 -80.290604 8.0 NaN US US-FL Miami 1 KMIA MIA MIA http://www.miami-airport.com/ http://en.wikipedia.org/wiki/Miami_Internation... MFW, South Florida 1073075 2008-06-13T14:30:04+00:00
15 3602 KIAD large_airport Washington Dulles International Airport 38.944500 -77.455803 312.0 NaN US US-DC Washington 1 KIAD IAD IAD http://www.mwaa.com/dulles/ http://en.wikipedia.org/wiki/Washington_Dulles... WAS 1023875 2010-01-23T11:27:53+00:00
16 3643 KLGA large_airport La Guardia Airport 40.777199 -73.872597 21.0 NaN US US-NY New York 1 KLGA LGA LGA http://www.panynj.gov/CommutingTravel/airports... http://en.wikipedia.org/wiki/LaGuardia_Airport Manhattan, New York City, NYC, Glenn H. Curtis... 1030575 2010-01-23T11:27:55+00:00
17 3772 KPHX large_airport Phoenix Sky Harbor International Airport 33.434299 -112.012001 1135.0 NaN US US-AZ Phoenix 1 KPHX PHX PHX http://phoenix.gov/skyharborairport/ http://en.wikipedia.org/wiki/Phoenix_Sky_Harbo... NaN 1060875 2008-06-13T14:30:04+00:00
18 2429 EGKK large_airport London Gatwick Airport 51.148102 -0.190278 202.0 EU GB GB-ENG London 1 EGKK LGW NaN http://www.gatwickairport.com/ http://en.wikipedia.org/wiki/London_Gatwick_Ai... LON, Crawley, Charlwood 1049275 2009-01-30T17:53:54+00:00
19 3875 KSEA large_airport Seattle Tacoma International Airport 47.449001 -122.308998 433.0 NaN US US-WA Seattle 1 KSEA SEA SEA http://www.portseattle.org/seatac/ http://en.wikipedia.org/wiki/Seattle-Tacoma_In... NaN 1038675 2008-06-13T14:30:04+00:00
20 3422 KBOS large_airport General Edward Lawrence Logan International Ai... 42.364300 -71.005203 20.0 NaN US US-MA Boston 1 KBOS BOS BOS http://www.massport.com/logan/ http://en.wikipedia.org/wiki/Logan_Internation... General Edward Lawrence Logan International Ai... 1035875 2010-01-23T11:27:48+00:00
21 3771 KPHL large_airport Philadelphia International Airport 39.871899 -75.241096 36.0 NaN US US-PA Philadelphia 1 KPHL PHL PHL http://www.phl.org/ http://en.wikipedia.org/wiki/Philadelphia_Inte... NaN 1031075 2008-06-13T14:30:04+00:00
22 1990 CYYZ large_airport Lester B. Pearson International Airport 43.677200 -79.630600 569.0 NaN CA CA-ON Toronto 1 CYYZ YYZ YYZ http://www.gtaa.com/ http://en.wikipedia.org/wiki/Toronto_Pearson_I... YTO, Toronto International Airport, Malton 1040275 2009-10-15T13:44:39+00:00
23 3483 KDCA large_airport Ronald Reagan Washington National Airport 38.852100 -77.037697 15.0 NaN US US-DC Washington 1 KDCA DCA DCA http://www.flyreagan.com/dca/reagan-national-a... http://en.wikipedia.org/wiki/Ronald_Reagan_Was... WAS 1016175 2016-12-13T09:13:00+00:00
24 3604 KIAH large_airport George Bush Intercontinental Houston Airport 29.984400 -95.341400 97.0 NaN US US-TX Houston 1 KIAH IAH IAH http://www.fly2houston.com/iah http://en.wikipedia.org/wiki/George_Bush_Inter... QHO 1055675 2008-06-13T14:30:04+00:00
25 3457 KCLT large_airport Charlotte Douglas International Airport 35.214001 -80.943100 748.0 NaN US US-NC Charlotte 1 KCLT CLT CLT http://www.charlotteairport.com/ http://en.wikipedia.org/wiki/Charlotte/Douglas... NaN 1028075 2009-01-30T14:52:52+00:00
26 3497 KDTW large_airport Detroit Metropolitan Wayne County Airport 42.212399 -83.353401 645.0 NaN US US-MI Detroit 1 KDTW DTW DTW http://www.metroairport.com/ http://en.wikipedia.org/wiki/Detroit_Metropoli... DTT, Detroit Metro Airport 1079375 2008-06-13T14:30:04+00:00
27 2218 EDDM large_airport Munich International Airport 48.353802 11.786100 1487.0 EU DE DE-BY Munich 1 EDDM MUC NaN http://www.munich-airport.com/ http://en.wikipedia.org/wiki/Munich_Internatio... Franz Josef Strauss International Airport, Flu... 1026675 2015-10-17T03:56:24+00:00
28 3709 KMSP large_airport Minneapolis-St Paul International/Wold-Chamber... 44.882000 -93.221802 841.0 NaN US US-MN Minneapolis 1 KMSP MSP MSP http://www.mspairport.com/ http://en.wikipedia.org/wiki/Minneapolis-Saint... NaN 1085275 2009-12-17T08:53:11+00:00
29 4372 LIRF large_airport Leonardo da Vinci–Fiumicino Airport 41.800278 12.238889 13.0 EU IT IT-62 Rome 1 LIRF FCO RM11 http://www.adr.it/portal/portal/adr/Fiumicino/... http://en.wikipedia.org/wiki/Leonardo_da_Vinci... ROM, Rome Fiumicino Airport, Fiumicino Airport 1031875 2016-10-08T00:37:02+00:00
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
6695 3567 KGSB large_airport Seymour Johnson Air Force Base 35.339401 -77.960602 109.0 NaN US US-NC Goldsboro 0 KGSB GSB GSB http://www.seymourjohnson.af.mil/ http://en.wikipedia.org/wiki/Seymour_Johnson_A... NaN 850 2014-10-04T01:51:25+00:00
6696 3914 KSZL large_airport Whiteman Air Force Base 38.730301 -93.547897 870.0 NaN US US-MO Knob Noster 0 KSZL SZL SZL http://www.whiteman.af.mil/ http://en.wikipedia.org/wiki/Whiteman_Air_Forc... Sedalia Glider Base 850 2015-05-31T03:54:50+00:00
6697 3391 KBAB large_airport Beale Air Force Base 39.136101 -121.436996 113.0 NaN US US-CA Marysville 0 KBAB BAB BAB NaN http://en.wikipedia.org/wiki/Beale_Air_Force_Base NaN 850 2012-06-21T01:43:23+00:00
6698 3715 KMUO large_airport Mountain Home Air Force Base 43.043598 -115.872002 2996.0 NaN US US-ID Mountain Home 0 KMUO MUO MUO http://www.mountainhome.af.mil/ https://en.wikipedia.org/wiki/Mountain_Home_Ai... NaN 850 2016-05-31T09:36:32+00:00
6699 3573 KGUS large_airport Grissom Air Reserve Base 40.648102 -86.152100 812.0 NaN US US-IN Peru 0 KGUS GUS GUS http://www.grissom.afrc.af.mil/ http://en.wikipedia.org/wiki/Grissom_Air_Reser... NaN 850 2014-10-03T23:32:05+00:00
6700 5510 RCBS large_airport Kinmen Airport 24.427900 118.359001 93.0 AS TW TW-X-KM Shang-I 1 RCBS KNH NaN http://www.kma.gov.tw/index-e.htm http://en.wikipedia.org/wiki/Kinmen_Airport Shang Yi Airport, 金門尚義機場, 金门尚义机场, Jīnmén Shàng... 850 2009-07-11T09:13:57+00:00
7035 6061 SELT large_airport Cotopaxi International Airport -0.906833 -78.615799 9205.0 SA EC EC-X Latacunga 1 SELT LTX NaN http://www.dgac.gob.ec/latacunga/ http://es.wikipedia.org/wiki/Aeropuerto_Intern... Latacunga, Vulcano, Ecuador, Cargo, Long runwa... 400 2013-02-25T10:27:48+00:00
10197 42924 RU-0035 large_airport Grozny North Airport 43.388302 45.698601 548.0 EU RU RU-CE Grozny 1 URMG GRV NaN NaN https://en.wikipedia.org/wiki/Grozny_Airport Grozny Severny, Grozny, Аэропорт Грозный Север... 0 2016-05-31T10:29:00+00:00
10260 299238 rjns large_airport Mt. Fuji Shizuoka Airport 34.796043 138.187752 433.0 AS JP JP-22 Makinohara / Shimada 1 RJNS FSZ NaN http://www.mtfuji-shizuokaairport.jp/english/i... http://en.wikipedia.org/wiki/Shizuoka_Airport NaN 0 2013-09-29T13:51:58+00:00
10316 320984 GB-0458 large_airport [Duplicate] Pic 55.505694 -4.586792 NaN EU GB GB-SCT Prestwick 0 NaN NaN NaN NaN NaN NaN 0 2016-11-12T08:02:29+00:00
10381 309668 DNAI large_airport Akwa Ibom International Airport 4.872500 8.093000 170.0 AF NG NG-AK Uyo 1 DNAI QUO NaN http://www.ibomairport.com.ng/ http://en.wikipedia.org/wiki/Akwa_Ibom_Airport NaN 0 2013-09-28T12:53:18+00:00
10407 27197 ZGNN large_airport Nanning Wuxu Airport 22.608299 108.171997 421.0 AS CN CN-45 Nanning 1 ZGNN NNG NaN http://www.nnairport.com/ http://en.wikipedia.org/wiki/Nanning_Wuxu_Inte... 南宁吴圩机场, Nanning Wuxu Air Base 1200 2009-04-16T20:31:13+00:00
10418 27195 ZGHA large_airport Changsha Huanghua International Airport 28.189199 113.220001 217.0 AS CN CN-43 Changsha 1 ZGHA CSX NaN NaN http://en.wikipedia.org/wiki/Changsha_Huanghua... 长沙黄花国际机场 1050 2013-05-17T01:38:00+00:00
10500 4168 LFOA large_airport Avord (BA 702) Air Base 47.053299 2.632500 580.0 EU FR FR-F Avord 0 LFOA NaN NaN NaN https://en.wikipedia.org/wiki/Avord_Air_Base NaN 850 2016-05-31T09:37:29+00:00
10501 35102 RU-2244 large_airport Ukrainka Air Base 51.169997 128.445007 771.0 EU RU RU-AMU Belogorsk 0 NaN NaN XHBU NaN http://en.wikipedia.org/wiki/Ukrainka_(air_base) ЬХБУ, Украинка 850 2017-01-20T18:03:03+00:00
10502 30601 PK-0001 large_airport (Under construction) New Islamabad Internation... 33.560714 72.851614 646.0 AS PK PK-PB Islamabad 0 NaN NaN NaN http://www.niia.com.pk/ http://en.wikipedia.org/wiki/New_Islamabad_Int... Fateh Jang 850 2010-12-28T15:14:35+00:00
10503 41136 RU-0016 large_airport Lipetsk Air Base 52.634998 39.445000 636.0 EU RU RU-LIP Lipetsk 0 NaN NaN NaN NaN http://en.wikipedia.org/wiki/Lipetsk_Air_Base NaN 850 2008-08-11T13:10:57+00:00
10504 35046 RU-4464 large_airport Olenya Air Base 68.151802 33.463902 702.0 EU RU RU-MUR Olenegorsk 0 NaN NaN XLMO NaN http://en.wikipedia.org/wiki/Olenya_(air_base) ЬЛМО, Оленья, Olenegorsk 850 2015-09-25T10:50:57+00:00
10506 42967 UUBW large_airport Zhukovsky International Airport 55.553299 38.150002 377.0 EU RU RU-MOS Zhukovsky 1 UUBW ZIA NaN http://zia.aero/ https://en.wikipedia.org/wiki/Zhukovsky_Intern... Аэропорт Раменское, Zhukovsky Air Base, Gromov... 850 2016-10-05T13:48:10+00:00
11631 34954 UWKG large_airport Borisoglebskoye Airport 55.866699 49.133301 213.0 EU RU RU-TA Kazan 0 UWKG NaN NaN NaN http://en.wikipedia.org/wiki/Borisoglebskoye_A... Аэропорт Борисоглебское 250 2015-08-21T19:49:50+00:00
41518 309579 VCRI large_airport Mattala Rajapaksa International Airport 6.284467 81.124128 157.0 AS LK LK-3 NaN 1 VCRI HRI VCRI http://www.mria.lk/ http://en.wikipedia.org/wiki/Mattala_Rajapaksa... Hambantota International Airport 0 2015-10-06T05:20:29+00:00
42016 317314 US-0303 large_airport atl 33.137551 -84.375000 NaN NaN US US-U-A NaN 1 NaN NaN NaN NaN NaN NaN 0 2016-03-19T09:20:40+00:00
42399 320983 CA-0671 large_airport Cyll 53.310365 -110.072021 NaN NaN CA CA-U-A NaN 1 NaN NaN NaN NaN NaN NaN 0 2016-10-31T22:20:17+00:00
42571 322136 YYZ large_airport Toronto Pearson International Airport 0.000000 0.000000 NaN NaN CA CA-ON NaN 1 NaN YYZ NaN NaN NaN NaN 0 2017-02-12T14:34:35+00:00
42689 299747 OM-0004 large_airport Rustaq Airport 23.640556 57.487500 349.0 AS OM OM-BA Al Masna'ah 0 OORQ MNH NaN NaN https://en.wikipedia.org/wiki/Rustaq_Airport Musanaa, Wadi al Maawil, Al Muladdah 0 2016-03-16T00:34:25+00:00
43270 44093 ZBNY large_airport Beijing Nanyuan Airport 39.782799 116.388000 NaN AS CN CN-11 Beijing 1 ZBNY NAY NaN NaN http://en.wikipedia.org/wiki/Nanyuan_Airport NaN 0 2009-08-30T19:53:52+00:00
44663 299738 OM-0003 large_airport Duqm Jaaluni Airport 19.500000 57.642800 380.0 AS OM OM-WU Duqm 1 OODQ JNJ NaN http://www.omanairports.com/ https://en.wikipedia.org/wiki/Duqm_Jaaluni_Air... NaN 0 2016-05-31T09:45:53+00:00
47391 302303 RKJB large_airport Muan International Airport 34.991406 126.382814 35.0 AS KR KR-46 Muan 1 RKJB MWX NaN http://muan.airport.co.kr/doc/muan_eng/ http://en.wikipedia.org/wiki/Muan_Internationa... Gwangju, Mokpo 0 2015-08-19T02:40:29+00:00
48343 45229 AMC large_airport Mar de Cortés International Airport 31.351621 -113.305864 71.0 NaN MX MX-SON Puerto Peñasco 1 MMPE PPE NaN NaN http://en.wikipedia.org/wiki/Mar_de_Cort%C3%A9... NaN 0 2016-05-31T10:21:05+00:00
48768 309298 ID-0017 large_airport Sungai Siring International Airport -0.373611 117.255556 82.0 AS ID ID-KI Samarinda 1 NaN NaN NaN http://www.proyek.dishubprovkaltim.info/?pro=1 http://en.wikipedia.org/wiki/Samarinda_Interna... Sungai Siring Airport, فرودگاه سیرینگ 0 2015-02-15T02:52:02+00:00

574 rows × 20 columns

Since both latitude and longitude are columns in the dataframe we can use pandas to carry out a limited number of geospatial queries. For example, extract all the airports in the northern hemisphere:

df[df.latitude_deg > 0.0]
id ident type name latitude_deg longitude_deg elevation_ft continent iso_country iso_region municipality scheduled_service gps_code iata_code local_code home_link wikipedia_link keywords score last_updated
0 2434 EGLL large_airport London Heathrow Airport 51.470600 -0.461941 83.0 EU GB GB-ENG London 1 EGLL LHR NaN http://www.heathrowairport.com/ http://en.wikipedia.org/wiki/London_Heathrow_A... LON, Londres 1251675 2016-02-09T10:54:31+00:00
1 3632 KLAX large_airport Los Angeles International Airport 33.942501 -118.407997 125.0 NaN US US-CA Los Angeles 1 KLAX LAX LAX http://www.iflylax.com/ http://en.wikipedia.org/wiki/Los_Angeles_Inter... NaN 1335475 2010-01-23T11:27:55+00:00
2 3754 KORD large_airport Chicago O'Hare International Airport 41.978600 -87.904800 672.0 NaN US US-IL Chicago 1 KORD ORD ORD http://www.flychicago.com/ohare/en/home/Pages/... http://en.wikipedia.org/wiki/O'Hare_Internatio... CHI, Orchard Place 1503175 2014-08-19T18:55:27+00:00
3 3622 KJFK large_airport John F Kennedy International Airport 40.639801 -73.778900 13.0 NaN US US-NY New York 1 KJFK JFK JFK http://www.panynj.gov/CommutingTravel/airports... http://en.wikipedia.org/wiki/John_F._Kennedy_I... Manhattan, New York City, NYC, Idlewild 1052075 2010-01-23T11:27:54+00:00
4 3384 KATL large_airport Hartsfield Jackson Atlanta International Airport 33.636700 -84.428101 1026.0 NaN US US-GA Atlanta 1 KATL ATL ATL http://www.atlanta-airport.com/ http://en.wikipedia.org/wiki/Hartsfield-Jackso... NaN 2002475 2008-06-13T14:30:04+00:00
5 4185 LFPG large_airport Charles de Gaulle International Airport 49.012798 2.550000 392.0 EU FR FR-J Paris 1 LFPG CDG NaN http://www.aeroportsdeparis.fr/ http://en.wikipedia.org/wiki/Charles_de_Gaulle... PAR, Aéroport Roissy-Charles de Gaulle, Roissy... 1127475 2010-01-05T18:17:43+00:00
6 3878 KSFO large_airport San Francisco International Airport 37.618999 -122.375000 13.0 NaN US US-CA San Francisco 1 KSFO SFO SFO http://www.flysfo.com/ http://en.wikipedia.org/wiki/San_Francisco_Int... QSF, QBA 1112475 2008-06-13T14:30:04+00:00
7 2513 EHAM large_airport Amsterdam Airport Schiphol 52.308601 4.763890 -11.0 EU NL NL-NH Amsterdam 1 EHAM AMS NaN http://www.schiphol.nl/ http://en.wikipedia.org/wiki/Amsterdam_Schipho... NaN 1093275 2011-10-05T23:26:15+00:00
8 2212 EDDF large_airport Frankfurt am Main International Airport 50.033333 8.570556 364.0 EU DE DE-HE Frankfurt-am-Main 1 EDDF FRA NaN http://www.frankfurt-airport.de/ http://en.wikipedia.org/wiki/Frankfurt_Airport EDAF, Rhein-Main Air Base 1144675 2016-09-15T03:34:21+00:00
9 3521 KEWR large_airport Newark Liberty International Airport 40.692501 -74.168701 18.0 NaN US US-NJ Newark 1 KEWR EWR EWR http://www.panynj.gov/CommutingTravel/airports... http://en.wikipedia.org/wiki/Newark_Liberty_In... Manhattan, New York City, NYC 1064475 2008-06-13T14:30:04+00:00
10 3631 KLAS large_airport McCarran International Airport 36.080101 -115.152000 2181.0 NaN US US-NV Las Vegas 1 KLAS LAS LAS http://www.mccarran.com/ http://en.wikipedia.org/wiki/McCarran_Internat... NaN 1068475 2010-07-05T16:48:39+00:00
11 3488 KDFW large_airport Dallas Fort Worth International Airport 32.896801 -97.038002 607.0 NaN US US-TX Dallas-Fort Worth 1 KDFW DFW DFW http://www.dfwairport.com/ http://en.wikipedia.org/wiki/Dallas-Fort_Worth... QDF 1203175 2008-06-13T14:30:04+00:00
12 3670 KMCO large_airport Orlando International Airport 28.429399 -81.308998 96.0 NaN US US-FL Orlando 1 KMCO MCO MCO http://www.orlandoairports.net/ http://en.wikipedia.org/wiki/Orlando_Internati... Disney World,Epcot Center 1044075 2008-06-13T14:30:04+00:00
13 3486 KDEN large_airport Denver International Airport 39.861698 -104.672997 5431.0 NaN US US-CO Denver 1 KDEN DEN DEN http://www.flydenver.com/ http://en.wikipedia.org/wiki/Denver_Internatio... DVX, KVDX 1103275 2015-11-13T09:28:42+00:00
14 3685 KMIA large_airport Miami International Airport 25.793200 -80.290604 8.0 NaN US US-FL Miami 1 KMIA MIA MIA http://www.miami-airport.com/ http://en.wikipedia.org/wiki/Miami_Internation... MFW, South Florida 1073075 2008-06-13T14:30:04+00:00
15 3602 KIAD large_airport Washington Dulles International Airport 38.944500 -77.455803 312.0 NaN US US-DC Washington 1 KIAD IAD IAD http://www.mwaa.com/dulles/ http://en.wikipedia.org/wiki/Washington_Dulles... WAS 1023875 2010-01-23T11:27:53+00:00
16 3643 KLGA large_airport La Guardia Airport 40.777199 -73.872597 21.0 NaN US US-NY New York 1 KLGA LGA LGA http://www.panynj.gov/CommutingTravel/airports... http://en.wikipedia.org/wiki/LaGuardia_Airport Manhattan, New York City, NYC, Glenn H. Curtis... 1030575 2010-01-23T11:27:55+00:00
17 3772 KPHX large_airport Phoenix Sky Harbor International Airport 33.434299 -112.012001 1135.0 NaN US US-AZ Phoenix 1 KPHX PHX PHX http://phoenix.gov/skyharborairport/ http://en.wikipedia.org/wiki/Phoenix_Sky_Harbo... NaN 1060875 2008-06-13T14:30:04+00:00
18 2429 EGKK large_airport London Gatwick Airport 51.148102 -0.190278 202.0 EU GB GB-ENG London 1 EGKK LGW NaN http://www.gatwickairport.com/ http://en.wikipedia.org/wiki/London_Gatwick_Ai... LON, Crawley, Charlwood 1049275 2009-01-30T17:53:54+00:00
19 3875 KSEA large_airport Seattle Tacoma International Airport 47.449001 -122.308998 433.0 NaN US US-WA Seattle 1 KSEA SEA SEA http://www.portseattle.org/seatac/ http://en.wikipedia.org/wiki/Seattle-Tacoma_In... NaN 1038675 2008-06-13T14:30:04+00:00
20 3422 KBOS large_airport General Edward Lawrence Logan International Ai... 42.364300 -71.005203 20.0 NaN US US-MA Boston 1 KBOS BOS BOS http://www.massport.com/logan/ http://en.wikipedia.org/wiki/Logan_Internation... General Edward Lawrence Logan International Ai... 1035875 2010-01-23T11:27:48+00:00
21 3771 KPHL large_airport Philadelphia International Airport 39.871899 -75.241096 36.0 NaN US US-PA Philadelphia 1 KPHL PHL PHL http://www.phl.org/ http://en.wikipedia.org/wiki/Philadelphia_Inte... NaN 1031075 2008-06-13T14:30:04+00:00
22 1990 CYYZ large_airport Lester B. Pearson International Airport 43.677200 -79.630600 569.0 NaN CA CA-ON Toronto 1 CYYZ YYZ YYZ http://www.gtaa.com/ http://en.wikipedia.org/wiki/Toronto_Pearson_I... YTO, Toronto International Airport, Malton 1040275 2009-10-15T13:44:39+00:00
23 3483 KDCA large_airport Ronald Reagan Washington National Airport 38.852100 -77.037697 15.0 NaN US US-DC Washington 1 KDCA DCA DCA http://www.flyreagan.com/dca/reagan-national-a... http://en.wikipedia.org/wiki/Ronald_Reagan_Was... WAS 1016175 2016-12-13T09:13:00+00:00
24 3604 KIAH large_airport George Bush Intercontinental Houston Airport 29.984400 -95.341400 97.0 NaN US US-TX Houston 1 KIAH IAH IAH http://www.fly2houston.com/iah http://en.wikipedia.org/wiki/George_Bush_Inter... QHO 1055675 2008-06-13T14:30:04+00:00
25 3457 KCLT large_airport Charlotte Douglas International Airport 35.214001 -80.943100 748.0 NaN US US-NC Charlotte 1 KCLT CLT CLT http://www.charlotteairport.com/ http://en.wikipedia.org/wiki/Charlotte/Douglas... NaN 1028075 2009-01-30T14:52:52+00:00
26 3497 KDTW large_airport Detroit Metropolitan Wayne County Airport 42.212399 -83.353401 645.0 NaN US US-MI Detroit 1 KDTW DTW DTW http://www.metroairport.com/ http://en.wikipedia.org/wiki/Detroit_Metropoli... DTT, Detroit Metro Airport 1079375 2008-06-13T14:30:04+00:00
27 2218 EDDM large_airport Munich International Airport 48.353802 11.786100 1487.0 EU DE DE-BY Munich 1 EDDM MUC NaN http://www.munich-airport.com/ http://en.wikipedia.org/wiki/Munich_Internatio... Franz Josef Strauss International Airport, Flu... 1026675 2015-10-17T03:56:24+00:00
28 3709 KMSP large_airport Minneapolis-St Paul International/Wold-Chamber... 44.882000 -93.221802 841.0 NaN US US-MN Minneapolis 1 KMSP MSP MSP http://www.mspairport.com/ http://en.wikipedia.org/wiki/Minneapolis-Saint... NaN 1085275 2009-12-17T08:53:11+00:00
29 4372 LIRF large_airport Leonardo da Vinci–Fiumicino Airport 41.800278 12.238889 13.0 EU IT IT-62 Rome 1 LIRF FCO RM11 http://www.adr.it/portal/portal/adr/Fiumicino/... http://en.wikipedia.org/wiki/Leonardo_da_Vinci... ROM, Rome Fiumicino Airport, Fiumicino Airport 1031875 2016-10-08T00:37:02+00:00
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
50599 44389 KZ-0071 closed Karas Air Base 48.737000 58.042000 NaN AS KZ KZ-AKT Zhem 0 NaN NaN NaN NaN NaN Emba Air Base, Аэродром Карась,Аэродром Эмба 0 2009-04-24T13:54:46+00:00
50600 44390 KZ-0072 closed Karas Air Base 48.737000 58.042000 NaN AS KZ KZ-AKT Zhem 0 NaN NaN NaN NaN NaN Emba Air Base, Аэродром Карась, Аэродром Эмба 0 2009-04-24T13:54:54+00:00
50601 319812 HSJ small_airport Shangjie Airport 34.842153 113.273983 450.0 AS CN CN-41 Zhengzhou 0 NaN HSJ NaN NaN NaN NaN 0 2016-08-06T20:22:46+00:00
50602 43684 UWKV medium_airport Zhigansk Airport 66.796501 123.361000 292.0 AS RU RU-SA Zhigansk 1 UEVV ZIX NaN NaN https://en.wikipedia.org/wiki/Zhigansk_Airport УЕЖЖ, Аэропорт Жиганск 0 2015-09-20T23:58:06+00:00
50603 308462 ZLZW medium_airport Zhongwei Shapotou Airport 37.573125 105.154454 8202.0 AS CN CN-64 Zhongwei 1 ZLZW ZHY NaN NaN http://en.wikipedia.org/wiki/Zhongwei_Shapotou... NaN 0 2013-04-10T00:28:33+00:00
50604 44386 KZ-0070 small_airport Zhosaly Airport 45.514999 64.084999 335.0 AS KZ KZ-KZY Zhosaly 0 NaN NaN NaN NaN NaN Dzhusaly Airport, Аэропорт Жосалы, Аэропорт Дж... 0 2009-04-24T13:34:01+00:00
50605 46369 UA-0071 closed Zhovti Vody Airstrip 48.350503 33.444271 NaN EU UA UA-12 Zhovti Vody 0 NaN NaN NaN NaN NaN Zholtyye Vody Airstrip, ЗПС Жовті Води, ВПП Жё... 0 2010-03-27T18:04:32+00:00
50606 46370 UA-0072 closed Volodimirivka Airstrip 48.284035 33.448949 NaN EU UA UA-12 Zhovti Vody 0 NaN NaN NaN NaN NaN ЗПС Володимирівка, ВПП Владимировка 0 2010-03-27T18:11:37+00:00
50607 44432 UKKO medium_airport Ozerne Air Base 50.158298 28.738300 761.0 EU UA UA-18 Zhytomyr 0 UKKO NaN NaN NaN https://en.wikipedia.org/wiki/Ozerne_(air_base) Zhitomyr Ozernoye, Oziernoye, Ozernoe, Ozernoy... 0 2017-02-18T21:11:10+00:00
50608 308157 DE-0040 small_airport Zierenberg Airfield 51.367000 9.336000 1450.0 EU DE DE-HE Zierenberg 0 NaN NaN NaN NaN NaN NaN 0 2012-12-15T23:37:53+00:00
50609 44743 RU-0197 small_airport Zimovniki Air Base 47.141998 42.395000 NaN EU RU RU-ROS Zimovniki 0 NaN NaN NaN NaN NaN Аэродром Зимовники 0 2009-08-17T10:56:36+00:00
50610 319653 MX-0257 small_airport El Pinocho Airport 19.476550 -100.433200 6265.0 NaN MX MX-MIC Zitácuaro 0 NaN NaN PIO NaN NaN NaN 0 2016-07-26T00:52:39+00:00
50611 43961 CZ-0044 heliport Bat’A Hospital Heliport 49.226147 17.705345 738.0 EU CZ CZ-ZL Zlín 0 NaN NaN NaN NaN NaN NaN 0 2009-03-27T18:08:04+00:00
50612 46129 RU-0304 medium_airport Kapustin Yar Airfield 48.667000 45.732000 NaN EU RU RU-AST Znamensk 0 NaN NaN NaN NaN NaN Аэродром Капустин Яр 0 2010-01-09T12:30:12+00:00
50613 319421 IT-0275 small_airport Campo di Volo Arcobaleno 44.496944 11.243611 NaN EU IT IT-45 Zola Predosa (BO) 0 NaN NaN BO11 NaN NaN NaN 0 2016-07-10T05:35:40+00:00
50614 45182 UA-0053 closed Palmira Airfield 49.763000 32.123000 NaN EU UA UA-71 Zolotonosha 0 NaN NaN NaN NaN NaN Аэродром Пальмира 0 2009-11-18T14:53:00+00:00
50615 319121 MX-0184 heliport Jupiter I Platform Helipad 19.520472 -92.184506 50.0 NaN MX MX-CAM Zonda De Campeche 0 NaN NaN HJU NaN NaN NaN 0 2016-06-25T00:38:37+00:00
50616 43747 EBZO heliport Zandvoorde heliport 50.817280 2.974564 102.0 EU BE BE-VWV Zonnebeke 0 EBZO NaN NaN NaN NaN NaN 0 2012-10-21T18:35:45+00:00
50618 43230 GE-0002 closed Zugdidi Airport 42.489201 41.818699 NaN AS GE GE-SZ Zugdidi 0 NaN NaN NaN NaN NaN NaN 0 2009-08-17T13:52:57+00:00
50620 298761 IT-0032 small_airport Campo di Volo Il Grifo 38.637255 15.947750 630.0 EU IT IT-78 Zungri 0 NaN NaN VVZUN http://www.aeroclubilgrifo.it NaN NaN 0 2017-01-03T03:03:17+00:00
50621 308403 ZUZY medium_airport Zunyi Xinzhou Airport 27.589500 107.000700 2920.0 AS CN CN-52 Zunyi 1 ZUZY ZYI NaN NaN http://en.wikipedia.org/wiki/Zunyi_Xinzhou_Air... NaN 0 2013-03-30T12:14:29+00:00
50622 316165 LDZE small_airport Zvekovac 45.823056 16.500000 374.0 EU HR HR-01 Zvekovac 0 LDZE NaN NaN http://www.akdubrava.net NaN NaN 0 2015-11-02T23:33:02+00:00
50623 44702 RU-0193 heliport Pushkino Heliport 56.042000 37.978001 NaN EU RU RU-MOS Zverosovkhoz 0 NaN NaN NaN http://www.agusta.ru/ NaN Вертодром Пушкино 0 2010-02-25T11:06:38+00:00
50624 43804 LOKZ heliport Zwatzhof Heliport 46.975555 14.274722 2500.0 EU AT AT-2 Zwatzhof 0 NaN NaN NaN NaN NaN NaN 0 2009-03-23T20:54:13+00:00
50625 43816 LOAZ heliport Zwettl Heliport 48.599998 15.164167 1900.0 EU AT AT-3 Zwettl 0 NaN NaN NaN NaN NaN NaN 0 2009-03-23T20:54:37+00:00
50626 43708 NL-0013 heliport Isala Klinieken. Locatie Sophia Heliport 52.513874 6.128000 6.0 EU NL NL-OV Zwolle 0 NaN NaN NaN NaN NaN EH0029 0 2009-03-21T16:38:26+00:00
50627 315523 RU-0438 small_airport Zyryanka West Airport 65.736700 150.705000 150.0 EU RU RU-SA Zyryanka 0 NaN NaN NaN NaN https://en.wikipedia.org/wiki/Zyryanka_West_Ai... ZCQ6, Зырянка (Западный) 0 2015-09-23T00:19:01+00:00
50628 318187 KZ-0081 small_airport Zubovsk Airport 49.800103 84.214661 NaN AS KZ KZ-VOS Zyryanovsk 0 NaN NaN NaN NaN NaN NaN 0 2016-05-31T03:11:45+00:00
50629 42246 BITH closed Sauðanes Airport 66.250603 -15.267200 15.0 EU IS IS-6 Þórshöfn 0 BITH NaN NaN NaN https://en.wikipedia.org/wiki/%C3%9E%C3%B3rsh%... THO 0 2015-08-20T20:43:01+00:00
50630 315917 BG-0027 small_airport Gabrovo 42.948200 25.359980 NaN EU BG BG-07 Габрово 0 NaN NaN NaN NaN NaN NaN 0 2015-10-20T12:54:39+00:00

39368 rows × 20 columns

  • Subsetting (querying but return dataframe not just indices)
gb = df.groupby('type')
gb.all()
id ident name latitude_deg longitude_deg elevation_ft continent iso_country iso_region municipality scheduled_service gps_code iata_code local_code home_link wikipedia_link keywords score last_updated
type
balloonport True True True True True True True True True True False True True True True True True False True
closed True True True False False False True True True True False True True True True True True False True
heliport True True True True True False True True True True False True True True True True True False True
large_airport True True True False False True True True True True False True True True True True True False True
medium_airport True True True True False False True True True True False True True True True True True False True
seaplane_base True True True True True False True True True True False True True True True True True False True
small_airport True True True True True False True True True True False True True True True True True False True
small = df[df.type=='small_airport']
medium = df[df.type=='medium_airport']
large = df[df.type=='large_airport']
len(small)
32875
len(medium)
4530
len(large)
574
  • spatial join - airports by countries
p = ('../data/airports/ne_10m_admin_0_countries/'\
     'ne_10m_admin_0_countries.shp')
countries_shp = gpd.read_file(p)
  • derived features - point sequence to line for the routes
  • spatial join - does route pass through a country
  • crs: contextily example,
  • knn analysis - find most isolated airport
  • voronoi - whats my closest airport
  • dissolve - dissovle boundaries in europe

Vignette: House Prices

df = pd.read_csv('../data/sandiego/listings.csv')
len(df)
6608
df.columns
Index(['id', 'listing_url', 'scrape_id', 'last_scraped', 'name', 'summary',
       'space', 'description', 'experiences_offered', 'neighborhood_overview',
       'notes', 'transit', 'access', 'interaction', 'house_rules',
       'thumbnail_url', 'medium_url', 'picture_url', 'xl_picture_url',
       'host_id', 'host_url', 'host_name', 'host_since', 'host_location',
       'host_about', 'host_response_time', 'host_response_rate',
       'host_acceptance_rate', 'host_is_superhost', 'host_thumbnail_url',
       'host_picture_url', 'host_neighbourhood', 'host_listings_count',
       'host_total_listings_count', 'host_verifications',
       'host_has_profile_pic', 'host_identity_verified', 'street',
       'neighbourhood', 'neighbourhood_cleansed',
       'neighbourhood_group_cleansed', 'city', 'state', 'zipcode', 'market',
       'smart_location', 'country_code', 'country', 'latitude', 'longitude',
       'is_location_exact', 'property_type', 'room_type', 'accommodates',
       'bathrooms', 'bedrooms', 'beds', 'bed_type', 'amenities', 'square_feet',
       'price', 'weekly_price', 'monthly_price', 'security_deposit',
       'cleaning_fee', 'guests_included', 'extra_people', 'minimum_nights',
       'maximum_nights', 'calendar_updated', 'has_availability',
       'availability_30', 'availability_60', 'availability_90',
       'availability_365', 'calendar_last_scraped', 'number_of_reviews',
       'first_review', 'last_review', 'review_scores_rating',
       'review_scores_accuracy', 'review_scores_cleanliness',
       'review_scores_checkin', 'review_scores_communication',
       'review_scores_location', 'review_scores_value', 'requires_license',
       'license', 'jurisdiction_names', 'instant_bookable',
       'cancellation_policy', 'require_guest_profile_picture',
       'require_guest_phone_verification', 'calculated_host_listings_count',
       'reviews_per_month'],
      dtype='object')
  • keyword table join (census) (keyword comes from spatial join with polygon shown below)

  • groupby: avg house price by census polygon

  • buffer: deriving dummies for houses within x of an amenity
  • spatial join: create keyword that we use for the table
  • raster/clip with shape: elevation or pollution by tract, or by house, or noise
  • voronoi - what's my closest coffee shop

  • Sets: union, intersection, difference: point out that these are really implied by the buffer used to define regimes (intersection dummy = 1, difference dummy=0)

message is, if you have the column in the table use it, but many cases you do not have the column and need to go the spatial join route