A feature set represents those
Feature objects that meet certain criteria.
Creates a feature set based on a Geographic Object Library.
france = Features("france") # All features in france.gol
To select a subset of features, add the constraint in parentheses, or apply a filter method. This always creates a new feature set, leaving the original set unmodified.
Select the features whose bounding boxes intersects the given
paris_bounds = Box( west=2.2, south=48.8, east=2.5, north=48.9) features_in_paris = france(paris_bounds)
Apply a query written in GOQL (the Geographic Object Query Language) to select features based on their type and tags:
restaurants = features( "na[amenity=restaurant]") # nodes and areas fire_hydrants = features( "n[emergency=fire_hydrant]") # only nodes safe_for_cycling = features( "w[highway=cycleway,path,living_street]," "w[highway][maxspeed < 30]") # linear ways
Select only features that are in both sets:
museums = features("na[tourism=museum]") in_paris = features.within(paris)) paris_museums = museums(in_paris)
Alternatively, you can use the
paris_museums = museums & in_paris
Iterate through the feature set:
>>> for hotel in hotels: ... print(hotel.name) Hôtel du Louvre Ambassadeur Brit Hotel
Turn it into a
>>> list(hotels) [way/112112065, relation/1575507, node/3558592188]
Check if the set is empty:
if pubs(within_dublin): print("Great, we can grab a beer in this town!") if not street.nodes("[traffic_calming=bump]"): print("No speed bumps on this street.")
The first feature of the set (or any arbitrary feature if the set is unordered).
None if the set is empty.
The one and only feature of the set.
QueryError is raised if the set is empty or contains more than one feature.
 to get the first
Feature of a non-empty set.
QueryError is raised if the set is empty.
first_node = way.nodes
These are read-only, and are calculated on each access.
The total number of features in this set.
The total area (in square meters) of all areas in this set.
The total length (in meters) of all features in this set. For areas, their circumference is used.
GeometryCollection that contains the shapes of all features in this set.
Only features that are nodes.
Only features that are ways (including areas that are represented using a closed way).
If you want to restrict the subset to linear ways, use
Only features that are relations (including relations that represent areas).
If you want to restrict the subset to non-area relations, use
The set’s features represented as GeoJSON (
restaurants.map.show() hotels.map.save("hotel-map") # .html by default hydrants.map(color='red') # map with fire hydrants marked in red
The set’s features represented as Well-Known Text (
Features that lie entirely inside geom.
Features that lie within the given distance from the centroid of geom. In lieu of a geometric object, you can also specify coordinates using
y (for Mercator-projected coordinates) or
lat (in degrees). Use
mercator_units to specify the maximum distance.
# All bus stops within 500 meters of the given restaurant features("n[highway=bus_stop]").around(restaurant, meters=500) # All features within 3 miles of the given point features.around(miles=3, lat=40.12, lon=-76.41)
Features whose geometry contains the given geometric object.
Note: If you want to test whether this set includes a particular feature, use
feature in set.
# In which park (if any) is this statue of Claude Monet? features("a[leisure=park]").contains(statue_of_monet).first # The county, state and country for this point -- should return # San Diego County, California, USA (in no particular order) features("a[boundary=administrative]" "[admin_level <= 6]").contains(Coordinate(lon=-117.25, lat=32.99))
As of Version 0.1.0, only nodes and
Coordinate objects are supported.
Features whose geometry crosses the given geometric object.
# All railway bridges across the Mississippi River features("w[railway][bridge]").crosses(mississippi)
Features whose geometry is disjoint from the given geometric object.
Features whose geometry intersects the given geometric object.
Features whose geometry overlaps the given geometric object.
Features whose geometry touches the given geometric object.
Features in ascending order of distance to the given geometric object.
- To limit the search radius, specify a maximum distance in the units of your choice:
These methods return a subset of those features that have a specific topological relationship with another
The nodes of the given way. Returns an empty set if feature is a node or relation.
Features that are members of the given relation, or nodes of the given way. Returns an empty set if feature is a node.
Relations that have the given feature as a member, as well as ways to which the given node belongs.
All features that share a common node with feature.
The license under which this dataset is made available.
The URL where the text of the license can be found.