Examples
For a gentler introduction and simpler examples, see the Tutorial.
Merge all counties within a 10 mile radius of Philadelphia
Given this FeatureCollection of counties in the Delaware Valley (del_val.geojson):
gq '
(
find(.properties.fips == "42101").geometry |
centroid |
buffer(10, {unit: "miles"})
) as $philly_buffer |
merge(.geometry | intersects($philly_buffer))
' del_val.geojson
This works by:
- Finding the
Featurecorresponding to Philadelphia county (FIPS county code of 42101) - Calculating the centroid of its geometry
- Generating a buffer with a radius of 10 miles around the centroid
- Merging all
Features whose geometries intersect with that buffer
Historical Markers in Philadelphia
Given this FeatureCollection of historical markers (historical_markers.geojson) and this FeatureCollection of the city limits of Philadelphia (City_Limits.geojson):
gq '
($2 | union) as $city_limits |
$1 |
filter(
.geometry != null and (
.geometry | contained_by($city_limits)
)
)
' historical_markers.geojson City_Limits.geojson
This works by:
- Unioning the geometries of all
Features within the city limitsFeatureCollection($2refers to the second input file) - Filtering the historical markers
FeatureCollection($1refers to the first input file) by non-null geometries falling within the city limits