Using this shapefile of the US counties at 1:500,000 resolution, I need to know, per county, the length from the centroid of that county to its furthest point away on its polygon. I would like the result in kilometers.
I have uploaded the shapefile to a PostGIS table with:
shp2pgsql -W LATIN1 gz_2010_us_050_00_500k.shp public.county_shapes | psql -h localhost -d counties -U jerickson
I did not know which SRID to use so I did not specify one.
Then, modifying this question/answer, I tried the following query, limiting to name = 'Missoula
(a county in Montana that I am familiar with) for now for testing:
SELECT
t.gid AS county_id,
max(ST_Distance(dump.geom, ST_Centroid(t.geom))) AS distance
FROM county_shapes t
JOIN ST_DumpPoints(t.geom) dump ON true
where name = 'Missoula'
GROUP BY 1
ORDER BY 1;
While this seems to be correct (logically), I am not sure how to get the resulting value (0.9038766878461234
) into kilometers. Using Google Earth to approximate the value, I would expect it to be at least 75 km.
How can I modify my process to get the distance from the centroid to the farthest point on the county polygon for each county in the shapefile?