Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Render shapefiles in opengl just like ArcGIS does

  1. #1
    Newbie Newbie
    Join Date
    Sep 2013
    Posts
    3

    Question Render shapefiles in opengl just like ArcGIS does

    Anyone interested in rendering geographic data with opengl! please help me

    As you know we have two kinds of coordinate systems in GIS : Geographic coordinate systems and projected coordinate systems
    consider these situations:

    I have a shapefile that has projected coordinate system, I mean the coordinates of the vertexes are in PCS, so there's no problem I can extract vertices with GDAL/OGR library and then show them in OpenGL with orthographic projection. since the coordinates are in meters and they're projected on a 2D plane, there will be no problem I think.

    The datasource has a geographic coordinate system and I just want to render it in a projected coordinate system, so I have to do the transformation with PROJ.4 library and then render the transformed coordinates in OpenGL. Again I think there will be no problem, since the coordinates I want to show areb projected on a 2D plane.

    The datasource has a geographic coordinate system and I want to render them in the the same GCS on an OpenGL window. So I extract coordinates with GDAL/OGR in geographic coordinate system and without any transformations, I'll render them in OpenGL. How can I achieve this? I mean how can I set up an ellipsoidal plane in an OpenGL window just like ArcGIS does renders data in geographic coordinate system?

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by sepideh View Post
    The datasource has a geographic coordinate system and I want to render them in the the same GCS on an OpenGL window. So I extract coordinates with GDAL/OGR in geographic coordinate system and without any transformations, I'll render them in OpenGL. How can I achieve this? I mean how can I set up an ellipsoidal plane in an OpenGL window just like ArcGIS does renders data in geographic coordinate system?
    You can use PROJ's pj_geodetic_to_geocentric() to convert geodetic (latitude, longitude, altitude) to geocentric (X,Y,Z) coordinates, or you can convert them yourself easily enough (just use the equations for spherical coordinates; a 297/298 ellipsoid is visually indistinguishable from a sphere, and there's not much point in getting it exact unless you know the physical aspect ratio of the monitor's pixels to better than 1/300).

  3. #3
    Newbie Newbie
    Join Date
    Sep 2013
    Posts
    3
    Quote Originally Posted by GClements View Post
    You can use PROJ's pj_geodetic_to_geocentric() to convert geodetic (latitude, longitude, altitude) to geocentric (X,Y,Z) coordinates, or you can convert them yourself easily enough (just use the equations for spherical coordinates; a 297/298 ellipsoid is visually indistinguishable from a sphere, and there's not much point in getting it exact unless you know the physical aspect ratio of the monitor's pixels to better than 1/300).
    but I don't mean I want to convert the coordinates to geocentric surely in that case I can treat coordinates like 3D coordinates and render them in an opengl window which has projection set up with glFrustrum. I mean I want to see coordinates in decimal degrees whenever I move over the window and the coordinates are shown in status bar.

  4. #4
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by sepideh View Post
    I mean I want to see coordinates in decimal degrees whenever I move over the window and the coordinates are shown in status bar.
    Then you'll need to be more specific about what you actually want. Saying "like ArcGIS" doesn't help unless you've actually seen ArcGIS.
    E.g. you say
    I want to render them in the the same GCS on an OpenGL window.
    Taken literally, that would require an ellipsoidal monitor. Displaying them on a flat monitor requires a projection. It doesn't have to be a standardised projection, but it needs to map lat/lon to x/y. Also, to convert screen coordinates back to geographic coordinates for the status bar requires that you can compute the inverse projection (PROJ can do this for some projections, others require root-finding).

  5. #5
    Newbie Newbie
    Join Date
    Sep 2013
    Posts
    3
    Quote Originally Posted by GClements View Post
    Then you'll need to be more specific about what you actually want. Saying "like ArcGIS" doesn't help unless you've actually seen ArcGIS.
    oh you're right then how can I change the title of the thread?
    I'm a new member to the forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •