Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I downloaded the shape file https://dati.comune.milano.it/media/rdp/comunemilano/dati/MM_FERMATE.7z, it represents the Milan's subway stations. I used ogrinfo to output the shapefile's summary and guess the SRID:

$ ogrinfo -summary MM_FERMATE.shp MM_FERMATE

INFO: Open of `MM_FERMATE.shp'
  using driver `ESRI Shapefile' successful.

Layer name: MM_FERMATE
Geometry: Point
Feature Count: 100
Extent: (1506722.964600, 5027236.460200) - (1534186.769400, 5043728.155000)
Layer SRS WKT:
PROJCS["Monte_Mario_Italy_zone_1",
GEOGCS["GCS_Monte Mario",
    DATUM["Monte_Mario",
    SPHEROID["International_1924",6378388,297]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",9],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",1500000],
PARAMETER["false_northing",0],
UNIT["Meter",1]]
ID: Integer (10.0)
FERMATA: String (100.0)
N_ARCHI: Integer (10.0)

Then I loaded the data in PostgreSQL:

shp2pgsql -s 3003 MM_FERMATE.shp | psql -d gis_sample

Finally I tried to convert "the_geom" field in degrees but I always got the same results.

Output using st_astext function:

gis_sample=# select st_astext(the_geom) from mm_fermate where n_archi = 4;
    st_astext             
----------------------------------
POINT(1515086.3214 5037713.221)
POINT(1516846.3194 5036826.4702)
POINT(1515864.6252 5036806.3372)
POINT(1514766.6816 5034612.3064)
POINT(1513860.5034 5034993.1312)
(5 rows)

Output using st_asewkt:

gis_sample=# select st_asewkt(the_geom) from mm_fermate where n_archi = 4;
        st_asewkt                  
--------------------------------------------
SRID=3003;POINT(1515086.3214 5037713.221)
SRID=3003;POINT(1516846.3194 5036826.4702)
SRID=3003;POINT(1515864.6252 5036806.3372)
SRID=3003;POINT(1514766.6816 5034612.3064)
SRID=3003;POINT(1513860.5034 5034993.1312)
(5 rows)

How can I get the lat/lon in degrees?

Below there's my PostGIS version:

gis_sample=# select PostGIS_Full_Version ();
                    postgis_full_version                                          
-------------------------------------------------------------------------------------------------------
POSTGIS="1.5.3" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.8.0" USE_STATS
(1 row)
share|improve this question

1 Answer 1

The ST_Transform function takes the desired coordinate system as the second parameter - see ST_Transform page for PostGis.

untested example ..

SELECT ST_AsText(ST_Transform(the_geom,4326)) As wgs_geom;
share|improve this answer
3  
If PostGIS 2.x is available and pretty lat/long output is desired, ST_AsLatLonText can be used in place of ST_AsText. –  Mike T Jul 29 at 5:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.