Skip to content

Instantly share code, notes, and snippets.

@danabauer
Last active May 1, 2024 18:58
Show Gist options
  • Save danabauer/34e176976cc4e4c0f1fc207f04c48398 to your computer and use it in GitHub Desktop.
Save danabauer/34e176976cc4e4c0f1fc207f04c48398 to your computer and use it in GitHub Desktop.
SELECT 
    id,
    names.primary AS primary_name,
    sources[1].dataset AS primary_source,
    ST_GeomFromBinary(geometry) AS geometry
FROM v2024_04_16_beta_0
WHERE type = 'building'
	AND ST_INTERSECTS(
		ST_GeomFromBinary(geometry),
		(
		SELECT 
	            ST_GeomFromBinary(geometry)
		FROM v2024_04_16_beta_0
		WHERE type = 'division_area'
		    AND subtype = 'locality'
		    AND country = 'US'
		    AND names.primary = 'Philadelphia'
		    ORDER BY ST_AREA(ST_GeomFromBinary(geometry)) DESC
		    LIMIT 1
		)
	);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment