I added .geojson files that I try to parse, but when I run the code it gives an error like; KeyError: 'area', I know its means but my question is how can I achieve the keys inside raw_airport.loc
https://dosya.co/93s8tuqpr86m/gates-and-ramps.geojson.html https://dosya.co/5to7l7ngutew/taxiways-and-runways.geojson.html
import geopandas as gpd
raw_airport = gpd.read_file('./taxiways-and-runways.geojson')
runway_paths = (
raw_airport.loc[lambda x: x['area'] != 'yes']
.loc[lambda x: x['aeroway'] == 'runway']
)
taxiway_paths = (
raw_airport.loc[lambda x: x['area'] != 'yes']
.loc[lambda x: x['aeroway'] == 'taxiway']
.loc[:, ['geometry']]
)
raw_stands = gpd.read_file('./gates-and-ramps.geojson')
stands = raw_stands.dropna(subset=['ref'])
CodePudding user response:
After running, at the right side you will see the "Variable Explorer" you can see the details on there.
CodePudding user response:
Yor problem is probably that keys are sometimes missing, causing expressions like x['area']
to throw a KeyError
. If you use the .get
method (i.e, x.get('area')
instead, you get None
(or a default value of your choice) when the key is missing.