# will ogr get coordinates in geographic coordinate system or projected coordinate system when using getPoint(int,OGRPoint*)

Consider the code that I have written in the stackoverflow question How to extract vertexes of geometries in ESRI shapefiles using ogr library with c++, I have used the code to show shapefiles on an OpenGL window and my problem is it seems the layer is stretched comparing to what is shown when we render it in ArcGIS, QGIS and etc that I think it is maybe because of not using the correct projection.

for a layer, like this:

are the vertex coordinates stored in Geographic coordinate system or projected coordinate system when we use functions like:

``````OGRLineString::getPoint(int,OGRPoint*);
OGRPoint::getX();
OGRPoint::getY();
``````

when I debug my code and see the vectors stored:

I come to the point that coordinates are stored in the PCS not GCS, but why my layer is stretched.
In fact I'm not sure what's the problem to start to solve. So just tell me:

• Are the coordinates fetched when we use the above functions in geographic coordinate system or in projected coordinate system?

Edited section based on the Andre Joost's comment
I have downloaded `Country Regions` dataset here, you see its coordinate system and bounding box here:
and the data stored is:

that you see is in decimal degrees. Now in ArcCatalog I change the coordinate system:
As you see the bounding box is not projected to the new coordinate system and they are the same number just their unit is in meters. Which is obviously not true:

and the data stored with for the same point in my program is:

So I think the projection is not done automatically and I should do the calculations with PROJ.4 library!

-

## 2 Answers

Your problem is an openGL logic problem. The interaction between your viewport command and projection command is such that the coordinates are being graphed in a coordinate system that fills the viewport that you have defined. You can see this by grabbing the right edge of your openGL window and resizing. The entire display rubber-bands with the shape of the screen.

I'm not that familiar with the structure of openGL programs, but your problem lies in the interaction of the viewport with the projection (glOrtho in this case). You need to get these coordinated so that shape is preserved. I would start with a very simple program- plotting a square - and make sure that no matter how you resize the window, it remains square. Once you get this understood, apply that logic to setting the viewport and projection for your shapefile program.

-
you're right. the problem is because glViewport and glOrtho. One of my previous programs has confused me! – sepideh Sep 15 '13 at 17:19

The verticers are stored in the coordinate system given in the .prj file. You can open that with any text editor.

The extent of the shapefile is in the same coordinate system.

The central meridian is the only value in degrees, all others are in meters when using UTM.

-
ok so you mean if I have drawn vertices in WGS 84 but the projection that is specified in .prj file is for example : PROJCS["WGS_1984_UTM_Zone_39N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROI‌​D["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.01‌​74532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",5000‌​00.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",51.0],PARAMETE‌​R["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] then the coordinates that I get with OGRPoint::getX() is in UTM and there's – sepideh Sep 15 '13 at 14:11
no need to do the projection calculations in my program? – sepideh Sep 15 '13 at 14:12
No, the data is already projected. In QGIS, it perfectly fits to Openstreetmap background. – AndreJ Sep 15 '13 at 14:49
thanks for your attention but I have made an editing to my question based on what you told. Please see it if you're desired to help me! – sepideh Sep 15 '13 at 15:52
I do not know ArcCatalog, but when you exchange the CRS in QGIS with `Set CRS for Layer`, no reprojection of coordinates is done by this. You have to save the layer into another file, and can select a different CRS for that. Then (and only then!) all points will be reprojected to the new CRS. – AndreJ Sep 15 '13 at 18:10