Antoine, 2163 (US National Atlas is an approximation of meters for Continental US). If you use it for anywhere else, it will become very inaccurate
To get better answers, use UTM zone Use the UTMzone function http://postgis.refractions.net/support/wiki/index.php?plpgsqlfunctions in wiki to determine right SRID for region. So would be SELECT ST_Transform(ST_Buffer(foofoo.the_geom_utm ,100), 4326) As buffer_geom, ST_distance_sphere(ST_Transform(ST_Centroid(ST_Buffer(foofoo.the_geom_utm ,100)),4326),ST_Transform(ST_StartPoint(ExteriorRing(ST_Buffer(foofoo.the_geom_utm ,100))),4326)) As dist_meters FROM (SELECT foo.the_geom, ST_Transform(foo.the_geom, utmzone(foo.the_geom) ) As the_geom_utm FROM (SELECT ST_GeomFromText('POINT(0.0 20)',4326) As the_geom) As foo) As foofoo --- Distance result = 99.76 meters -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lucas Antoine (External) Sent: Wednesday, October 22, 2008 3:24 AM To: 'PostGIS Users Discussion' Subject: RE: [postgis-users] making a circle with radius in meters, and lat/lon position Hi, Indeed, making a buffer in my SRID (4326) will not makes a perfect circle. But how to make a circle then ? area = transform(Buffer(transform(GeomFromText('POINT(0.0 20)',4326), 2163) ,100), 4326) should be the correct function (point in lat / lon, transformed in meters then circle, then back in lat lon). but then distance between a point of circle and the center: Distance( transform(ST_Centroid(area),2163), transform(PointN(ExteriorRing(area),1),2163)) return 100 meters distance_sphere(ST_Centroid(area),PointN(ExteriorRing(area),1)) return 127 meters. And also, when I get all points and try to compute radius by hand, I get again 127 meters. Why distance_sphere and Distance function do not return same result ? Antoine. -----Message d'origine----- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] la part de Michael Smedberg Envoyé : mardi 21 octobre 2008 22:30 À : PostGIS Users Discussion Objet : RE: [postgis-users] making a circle with radius in meters, and lat/lon position Hey Lucas, I'm not sure I 100% understand your question, but I think that you're making an incorrect assumption. When you " transform distance into angle and make buffer directly in my SRID (4326)", I don't think that the result will be a circle. For instance, when you're near the North Pole, a degree of longitude is shorter than a degree of latitude. If you were, say, 2 degrees south of the North Pole, and you drew a polygon around you that was one degree away, the result would not be a circle, and would be shorter (as measured in meters) in the East-West direction than in the North-South direction, right? In other words, I don't think you can draw a circle in 4326- a "circle" in degrees isn't a circle in actual distance. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lucas Antoine (External) Sent: Monday, October 20, 2008 12:35 AM To: '[email protected]' Subject: [postgis-users] making a circle with radius in meters,and lat/lon position Hi all, I am using postgis 1.2.1 and I would like to make a circle. I use meters unit and lat/lon coordinate in SRID 4326. I saw two solutions: * transform point to a meter-SRID 2163 then make a buffer in meters and back transform in my SRID (4326) * transform distance into angle and make buffer directly in my SRID (4326) To check result, I first watch all coords, then recompute center, and compute distance between center and a circle point. With function Distance: OK with function distance_sphere: 27% too much ! I made some verification by hand and I find a result close to distance_sphere; where is the mistake ? Here is a sample: -- SQL file create table toto (id int4 ); SELECT ADDGEOMETRYCOLUMN('public', 'toto', 'area', 4326, 'GEOMETRY', 2); -- insert a circle with 100 meter radius -- -- with transform function -- insert into toto (area) values (transform( Buffer( transform( GeomFromText('POINT(0.0 20)',4326), -- point in lat lon 2163) -- point in meters coords ,100), -- circle in meters coords 4326) ); -- circle in lat / lon -- insert a circle with 100 meter radius -- -- transform directly 100 meters to angle (approximation from 4326 model ?) -- insert into toto (area) values ( Buffer(GeomFromText('POINT(0.0 20)',4326),100.0/(6376500.0*3.14159*2.0)*360.0 ) ); -- -- distance with transform function (coherent with transform circle) -- select Distance( transform(ST_Centroid(area),2163), transform(PointN(ExteriorRing(area),1),2163)) from toto; distance ------------------ 99.9998086273481 -> ok 102.031862045723 -> ok (2 rows) -- -- distance with transform function (not coherent with transform circle) -- select distance_sphere(ST_Centroid(area),PointN(ExteriorRing(area),1)) from toto; distance_sphere ------------------ 127.779274484879 -> no ok ! 93.8880956491054 (2 rows) _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users ----------------------------------------- The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer. _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users
