Skip to content

Instantly share code, notes, and snippets.

@wchargin
Created August 7, 2024 18:11
Show Gist options
  • Save wchargin/601b71939958b83c862a8ee0414ca9e2 to your computer and use it in GitHub Desktop.
Save wchargin/601b71939958b83c862a8ee0414ca9e2 to your computer and use it in GitHub Desktop.
# Create GeoJSON `Feature` values
def feature: {type: "Feature", properties: {}, geometry: .};
# Create GeoJSON `Geometry` values
def geometry($type): {$type, geometry: .};
def point: geometry("Point");
def multipoint: geometry("MultiPoint");
def linestring: geometry("LineString");
def multilinestring: geometry("MultiLineString");
def polygon: geometry("Polygon");
def multipolygon: geometry("MultiPolygon");
# Convert from latitude/longitude structs to GeoJSON coordinates
def lnglat: [.lng, .lat];
def lonlat: [.lon, .lat];
def tude: [.longitude, .latitude];
# Convert from GeoJSON coordinates to latitude/longitude structs
def mklnglat: {lng: .[0], lat: .[1]};
def mklonlat: {lon: .[0], lat: .[1]};
def mktude: {longitude: .[0], latitude: .[1]};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment