We have a situation where we get a single lat/long point and a value for "acreage", and we need to draw a polygon circle that is roughly the size that the acreage value implies. What we have is a query that comes extremely close, but the total area is still off, for some reason.
create TEMP TABLE g (geom geometry, acres float);
insert into g VALUES (ST_SETSRID(ST_POINT(-74,34.00), 4326), 100);
insert into g VALUES (ST_SETSRID(ST_POINT(-74,34.00), 4326), 10000);
insert into g VALUES (ST_SETSRID(ST_POINT(-74,34.00), 4326), 100000);
create temp table gg AS select
ST_TRANSFORM(
ST_BUFFER(
-- Build a buffer, calculating radius as sqrt(area/pi)
geom::geography,
SQRT(
(acres/.00024711)/3.1415
)
)::geometry
, 4326)::geography as b,
acres,
acres/.00024711 as area_in_meters
FROM g;
SELECT
b,
st_area(b, TRUE), -- This and area_in_meters are not _quite_ equal
acres,
area_in_meters
FROM gg;
I believe its one of a few factors, but I am having a hard time deriving the right test.
acres/.00024711 as area_in_meters
- is this an accurate way of converting acres to sq meters?
ST_TRANSFORM(buffer_geom, 4326)
Will this always yield an accurate geometry for the buffer we want? are we loosing data jumping around between geography and geometry?
st_area(b, TRUE)
b is a geography, so this is in meters right? its what the docs say, but perhaps ::geography as b
isn't fully performing the cast I think it is?
PI*r*r
(or the more complex speroidal surface sector area calculation) instead.