How to get average of lat/long from cities by county that they're in I found this script but I'd like to get the average of the latitudes/longitudes so I can just have the latitude/longitude of the counties. I tried 

SELECT id, CITY, COUNTY, LONGITUDE, LATITUDE, AVG(LONGITUDE) AS val_1, AVG(LATITUDE) AS val_2
FROM directory_platform_cities 
GROUP BY id, COUNTY;


But it's just attaching the lat/long of the first city to the county, is there a query that can do this? My intention is to get the latitude/longitude of the counties using the coordinates of their respective cities.
My intention is to get the latitude/longitude of the counties using the coordinates of their respective cities.


This is insane and you should never do this. Counties aren't geographic and this isn't how GIS works. Moreover the cities inside the counties are totally useless for determining where the county is. Cities are near rivers, costs, railroads, and roads. Counties are just political hacks to disempower minorities, and make sure rich ranches in unincorporated territories have enough police to keep out ex-slaves.

So if you have to use counties, what you want you to do is use them as they are and not try to make sense of them.


Download the Cenus Shape Files for your state. They're distributed in the TIGER data set by state, and they have one or more polygons that represents each state's counties!
Run a query using ST_Within to determine what county your points are in.


There is no need to find any specific point in that polygon because it makes no sense.