Skip to content

Coordenadas UTM

Peter edited this page Sep 29, 2018 · 2 revisions

Uso do padrão nacional ...

... Ainda usam UTM para mapeamento de lotes na cidade? E a referência de grade, afinal usar qual? Citam "SF 23" ou "SF-23": ref1, ref2 e IBGE.

Reversibilidade

SELECT st_astext(st_transform(st_transform(
   ST_GeomFromText('POINT(-46.633947 -23.550394)',4326), 32723), 4326
));  -- bom ~ POINT(-46.633947 -23.550394)
SELECT st_astext(st_transform(st_transform( 
   ST_GeomFromText('POINT(-38.542778 -3.718333)',4326), 32723), 4326
));  -- bom ~ POINT(-38.542778 -3.718333)

How to convert usual WSG84 to UTM of specific cell?

As we see below, there are a "UTM standard" (what the specific official name?) where we express the coordinates not global bot the cell-coordinates.

São Paulo center is at UTM's 23K 333222 7394599, that is WSG84's -23.550394 -46.633947.

So, I try to transform POINT(-46.633947 -23.550394)... With the function below

     SELECT get_utmzone( ST_GeomFromText('POINT(-46.633947 -23.550394)',4326)); -- 32723
     SELECT st_astext(st_transform(  ST_GeomFromText('POINT(-46.633947 -23.550394)',4326),  32723  ));  

that results in a UTM coordinate 333221 7394599. Perfect (!).

Now try to do the same thing at WSG84 -3.718333 -38.542778, that Wikipedia say is UTM 24M 550772 9588994.

     SELECT get_utmzone( ST_GeomFromText('POINT(-38.542778 -3.718333)',4326)); -- 32724
     SELECT st_astext(st_transform(  ST_GeomFromText('POINT(-38.542778 -3.718333)',4326),  32724  ));  

results 550771 9588993 from UTM zone 24S that is not the SRID of the "UTM cell 24M"... What the complete procedure to obtain the exact coordinate.

It is a systematic error, not casual,

  • point3 at geo:-22.900833,-47.057222 is UTM 23K 288987 7465983. Result: 288987 7465983 (perfect!).

  • point4 at geo:-7.311111,-38.944444 is UTM 24M 506132 9191858. Result: 506132 9191858 ... Perfect!


NOTES

UTM grid

PS: Brasilian official name for 23K cell is also SF23 cell (as cited e.g. in this doc... Why? They are synonymous?

UTM Zones

    CREATE FUNCTION get_utmzone(
      p_geom geometry(POINT)
    ) RETURNS integer AS $f$
      SELECT CASE
        WHEN p_geom IS NULL OR GeometryType(p_geom) != 'POINT' THEN NULL
        ELSE floor((ST_X(p_geom)+180.0)/6.0)::int
             + CASE WHEN ST_Y(p_geom)>0.0 THEN 32601 ELSE 32701 END
        END
    $f$ LANGUAGE SQL IMMUTABLE;