Prints all features that match the given query to
stdout, in a variety of formats.
gol query [<options>] <gol-file> <query>
gol query geodata/france na[amenity=fire_station], n[emergency=fire_hydrant] -b=2.2,48.8,2.5,18.9 -f=geojson -u=https://www.mywebsite.com/myfeatures/france -n
retrieves all fire stations (which can be nodes or areas) and hydrants (which only exist as nodes) from the
france.gol library (stored in the
geodata folder). The features must lie fully or partially inside the specified bounding box (a rectangle that covers metropolitan Paris) and are printed to
stdout as GeoJSON (see below).
Tiles that are part of the query area, but that are not already present in the library, are downloaded from the specified URL. If the library itself does not yet exist, it is created (option
- The path of the library is resolved relative to the current directory. The
.golfile extension may be omitted.
Defines the area to which the command should be applied. Currently, only polygon files are supported.
Defines the rectangular area (bounding box) to which the command should be applied. Coordinates are specified in WGS-84 (degrees longitude and latitude) and take the form
<west>,<south>,<east>,<north>. Coordinates must not be separated by spaces (otherwise, they would be interpreted as separate arguments).
As an alternative, this option accepts a tile descriptor in the form
The output format of the results:
|Prints only the number of features.|
|GeoJSON (traditional / one feature per line)|
|Simple list of IDs (default)|
|Polygon file (areas only)|
|Statistics based on tags and roles|
|Simple text-based table|
|Well-known text (geometries only)|
OSM-XML output is not suitable for editing, since the IDs for untagged nodes won’t match the original OSM data (You can open these XML files in JOSM, but please don’t upload them).
Defines the style of IDs used for
|Omit the ID of features|
|OSM ID multiplied by 4 (+1 for ways, +2 for relations)|
|OSM ID multiplied by 10 (+1 for way, +2 for relations)|
|custom||A template that can use |
Keep in mind:
- OSM IDs are only unique within each OSM type (This means there could be a
waythat share the same ID).
- To avoid ID collisions, use a plain
$idonly if you are querying
- Areas (
a) can consist of both
relationfeatures, so the OSM type must be incorporated into the ID.
The maximum width (in characters) of the displayed table (used by
table. Default: 100
Specifies the sort order of results. By default, results are returned in no particular order.
Sorting may substantially increase memory consumption (and decrease performance), especially for large result sets (millions of features).
The maximum number of features to be displayed or counted.
A comma-separated list of OSM keys, which determine the feature tags to be included in the output.
There are several special keys that only apply to the
csv output option and produce additional columns:
| The bounding-box coordinates of the feature (West, South, East, North). For |
| The geometry of the feature (as well-known text).|
Only applies to
| The WGS-84 latitude of the feature's center (see |
| The WGS-84 longitude of the feature's center (see |
|A comma-separated list of key-value pairs, representing the keys of the tags that are not already printed in a column of their own.|
| The Mercator-projected X coordinate of the feature's center (see |
| The Mercator-projected Y coordinate of the feature's center (see |
--tags is omitted, all tags are included in the output.
--tags is ignored if the requested output format is
Use this option to create an empty
.gol file if the specified library does not exist (rather than failing with an error message). Combine this option with
--url to specify a tile repository from which the library will be populated.
The coordinate precision (digits after the decimal point) to use.
Applies only to
Specifies the URL of the remote repository from which tiles are downloaded into the library.
Be aware that
| have special meanings for the shell (re-directing/piping of the output stream), so if your query contains these characters, you will need to enclose it in quotes.
This won’t work:
gol query germany w[highway][maxspeed>100]
gol query germany "w[highway][maxspeed>100]"
To write the output of your query to a file:
gol query germany "w[highway][maxspeed>100]" -f:csv > fast-roads.csv
Also, be aware that the shell doesn’t play nicely with quotation marks (which are required if literal values in the query contain spaces or punctuation).
This won’t work:
gol query uk na[amenity=pub][name="The Howling Hound"]
The shell “eats” the double quotes instead of passing it to the GOL utility, which then reports an error. To avoid this problem, use single quotes:
gol query uk na[amenity=pub][name='The Howling Hound']
If the query string itself contains quotation characters, prefix them with a backslash (
gol query uk na[amenity=pub][name='King\'s Crossing'] gol query uk na[amenity=pub][name='The \"Happy\" Place']