Skip to content

Instantly share code, notes, and snippets.

@timrobertson100
Created August 9, 2017 15:35
Show Gist options
  • Save timrobertson100/f31e4ad51c5ec5087ce5d93d01d555b2 to your computer and use it in GitHub Desktop.
Save timrobertson100/f31e4ad51c5ec5087ce5d93d01d555b2 to your computer and use it in GitHub Desktop.
Export of GBIF record counts by 1 degree cell, addressed on south-west of cell
CREATE TABLE tim.tom_export ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' AS
SELECT
CAST(decimalLatitude AS INT) AS lat,
CAST(decimalLongitude AS INT) AS lng,
count(*) AS total
FROM
prod_a.occurrence_hdfs
WHERE
hasGeospatialIssues=0 AND decimalLatitude IS NOT NULL AND decimalLatitude IS NOT NULL
GROUP BY
CAST(decimalLatitude AS INT),
CAST(decimalLongitude AS INT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment