Q:

Create KML by date

I have the following table that is populated with new data once a day.
postgres=# \d modis_c6

    Table "public.modis_c6"
   Column   |            Type             | Collation | Nullable | Default
------------+-----------------------------+-----------+----------+---------
 latitude   | numeric(6,3)                |           |          |
 longitude  | numeric(6,3)                |           |          |
 brightness | numeric(4,1)                |           |          |
 scan       | double precision            |           |          |
 track      | double precision            |           |          |
 acq_date   | date                        |           |          |
 acq_time   | time without time zone      |           |          |
 satellite  | character varying           |           |          |
 confidence | double precision            |           |          |
 version    | character varying           |           |          |
 bright_t31 | numeric(4,1)                |           |          |
 frp        | double precision            |           |          |
 geog       | geography(Point,4326)       |           |          |
 dtg        | timestamp without time zone |           |          |

Indexes:
"modis_c6_geog_idx" gist (geog)

I want to create a daily kml.  I can select the correct fields with
select * from modis_c6 where acq_date = current_date - interval '1 day';

How do I process the results of the above query with the ST_AsKML function?

A:

I've not tested this, but I think the following should work:
SELECT latitude,   
    longitude,  
    brightness,
    scan,       
    track,      
    acq_date,   
    acq_time,   
    satellite, 
    confidence, 
    version,    
    bright_t31, 
    frp,       
    ST_AsKML(geog) AS geog,       
    dtg
FROM modis_c6
WHERE acq_date = current_date - interval '1 day';

