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 have an OpenLayers map with a vector layer to add points on. I'm using Google Maps as the base layer. After the point is added, I need to store the data in my database as lat/long and x/y. Can I transform the projection of the x/y points or convert the lat/long to x/y? The x/y that is on the point is in spherical mercator so it doesn't work for me.

Update: I'm not having any trouble converting the x/y to lat/long. I want to convert the x/y that I have to a different projection. I'm not sure that's the right terminology, but I need to convert the x/y values.

Update: The SRID I need is 3734. When I drop the point, the x/y is like: x: -9058948.6891836 y: 5035248.6338434

But what I need looks more like: x: 2282175.42 y: 545126.58

I'm also using PostGIS so if this is possible to do with PostGIS I'm open to that also.

share|improve this question
    
To which particular projection do you want to project to? What is its SRID? –  Devdatta Tengshe Mar 7 '13 at 6:48
    
I added more details above. –  bl8rchk Mar 7 '13 at 13:17

3 Answers 3

up vote 2 down vote accepted

As per your update, a PostGIS solution would work as well;

You need ST_Transform to project in the data Postgis from EPSG 3857 to EPSG 3734

SELECT ST_AsText( ST_Transform(
ST_GeomFromText('POINT(-9058948.6891836,5035248.6338434)',3857),3734)) As wgs_geom;
share|improve this answer
    
This worked! I'm very new to PostGIS so I didn't even think to use it to do the conversion. –  bl8rchk Mar 7 '13 at 14:51
    
Great! Glad to hear that it worked out. Please consider marking this answer as accepted. –  Devdatta Tengshe Mar 7 '13 at 15:23

Try to do more research before posting questions. I don't know openlayers, but I found the answer in googling your title "OpenLayers X/Y Projection" in 30 sec. See http://stackoverflow.com/questions/2601745/how-to-convert-vector-layer-coordinates-into-map-latitude-and-longitude-in-openl

var toProjection = new OpenLayers.Projection("EPSG:4326");
var fromProjection = new OpenLayers.Projection("EPSG:900913");
var convertedPoint = new OpenLayers.LonLat(x, y);
convertedPoint.transform(fromProjection, toProjection);
share|improve this answer
    
I'm not having any trouble converting the x/y to lat/long. I want to convert the x/y that I have to a different projection. I'm not sure that's the right terminology, but I need to convert the x/y values. –  bl8rchk Mar 7 '13 at 3:37

There's a library called proj4js can do this job, and you can use it together with OpenLayers. Have a look at OpenLayers Projection class.

share|improve this answer

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.