something like this (note that I'm not able to test it)
there are number of things you need to consider, e.g. N/S E/W of the coordinates (usually it is represented with -) does it affect the length? also decimal precision - you may need to round the float number for lon/lat to correct precision)
#!/usr/bin/python import psycopg2 from config import config import re import geojson import tempfile def parse_row(row): # extract lat, lon # you may need to round the float number to # correct number of decimal digits lon = float(row[3:15]) lat = float(row[15:27]) return (lon, lat) def get_vendorfield(): """ Connect to the PostgreSQL database server """ # read connection parameters params = config() # connect to the PostgreSQL server print('Connecting to the PostgreSQL database...') with psycopg2.connect(**params) as conn: # create a cursor with conn.cursor() as cur: try: cur.execute("SELECT t.id, t.\"vendorField\" FROM transactions t WHERE t.\"vendorField\" LIKE 'geo%'") print("Rows returned: ", cur.rowcount) #dashmap=(66, 3, 12, 12, 12, ) #this is used for the chunks - but the last chuck is missed because it is of unknown length geo_data = [parse_row(row[1]) for row in cur] # you may need to replace cur with cur.fetchall() except psycopg2.DatabaseError as db_error: print(error) geo_data = [] print('Database connection closed.') if geo_data: multipoint_json = geojson.Multipoint(geo_data) with open('points.json', 'w') as outfile: geojson.dump(multipoint_json, outfile, indent=2)My understanding was you want geojson.Multipoint file
there are number of things you need to consider, e.g. N/S E/W of the coordinates (usually it is represented with -) does it affect the length? also decimal precision - you may need to round the float number for lon/lat to correct precision)