>> GIS Education
Thread views: 13803 View all threadsNext thread*Threaded Mode

(Stranger )
12/09/08 10:48 PM
how to use wgs84 projection information (.shp) new Report this article as Inappropriate to us !!!Login to Reply


I am working on an application that involves some gis stuff. There
would be some .shp files to be read and plotted onto an opengl screen.
The current opengl screen is using the orthographic projection as set
from glOrtho()..and is already displaying a map using coordinates from
a simple text file..

now the map to be plotted is to be read from a shapefile.

I have the following doubt:

How to use the WGS84 projection of the .shp file(as read from the .prj
file of the shapefile,WKT format) into my existing glOrtho there any conversion that needs to be done? and how is
it different from what the glOrtho() sets up defaultly?basically how
to use this information?

Any inputs will be worth for me..because i am new to gis programming.


(Stranger )
12/23/08 08:20 AM
Re: how to use wgs84 projection information (.shp) new [re: ashishsony]Report this article as Inappropriate to us !!!Login to Reply


1.Shapefile rendering is quite straight forward in OpenGL.You may require "shapelib",a free shapefile parsing library in C(google for it).Use GL_POINTS for point shapefile,
GL_LINES for line shapefile and GL_LINE_LOOP for polygon shapefile.Set your bounding box coods to the Ortho.

2.What u read from .prj file is projection info.WGS84 gives u lat/long coods(Spherical).
But ur display system is 2D(Rectangular).So,u need to convert 3D Spherical coods to 2D Rectangular coods(This is the meaning of Projection).Projection types are numerous,depending on the area of interest on the globe(remeber projection distorts area/shape/size of features).Projection types range from Polyconic,Modified Everest,NAD,UTM etc.,

3.If u simly need WGS84 ,then read bounding box coods of ur sh file and assign them to glOrtho.If u have any projection(eg:-UTM) ,then u convert ur bounding box coods into Projection coods and then assign the newly projected coods to glOrtho.For converting lat/long into any Projection,u may require projection libraries like "Projlib" or "GeotransEngine" and etc.

For further clarifications u may contact me on dgplinux@ y a h o o . c o m

(Stranger )
12/25/08 05:24 AM
Re: how to use wgs84 projection information (.shp) [re: dgp]Report this article as Inappropriate to us !!!Login to Reply





Looking at things u seems to be new to GIS domain.I will answer to your questions one by one.

1)I suggest you go through Understanding_Map_Projections.pdf from ESRI ArcGIS s/w.(Google for it).It's 18MB ,so my internet speed would not be sufficient to send by myself.That should give you fairly good overview on projection stuff.

I suggest you use PROJ4 library( is no need to reinvent the wheel,coz this is a stable,opensource,widely accepted library on projections.And I bet it's quite an effort to write things from scratch. This  answers your Fifth&Sixth questions.

2)Your understanding(Third&Fourth points) on setting up glOrtho coods is absolutely correct.

3)As regards to your first&second queries,

a)Remember Lat/Longs spherical coods(Earth's shape) , are ANGULAR   DISTANCES.But, we all are interested in LINEAR MEASURES.So it is the business of projection libraries(eg:-PROJ4, to do the conversion for us.

b)WGS84 ,alternatively called as WCS or Geodetic system is just going to provide us with Lat/Long.If u have no serious calculations involved and you merely require maps to be dislayed ,then there is no harm in using WGS84.

If one is interested in more scientific calculations,one would use suitable projection depending on the application area or Geographic region.For instance,US army uses MGRS system ,US Geological survey uses UTM/NAD and India uses Polyconic(Modified EverestProjection).

You may not know in which projection a shapefile is in,unless it is accompanied by .prj file with the same name,which holds projection information.You may use Shapelib( to parse shapefile.The following section gives us the shapefile boundaries.If the boundaries are between -180 to 180 and -90 to 90 ,then we may assume it to be UnProjected(WGS84).If you get some other values,u must read the associated .prj file to ascertain the Projection.

For eg:-  SHPHandle hSHP=SHPOpen(fileName, "rb" );







View all threadsNext thread*Threaded Mode
Jump to


Textron - Countless CAD add-ons, plug-ins and more.

Internet Business Systems © 2016 Internet Business Systems, Inc.
595 Millich Dr., Suite 216, Campbell, CA 95008
+1 (408)-337-6870 — Contact Us, or visit our other sites:
AECCafe - Architectural Design and Engineering EDACafe - Electronic Design Automation TechJobsCafe - Technical Jobs and Resumes  MCADCafe - Mechanical Design and Engineering ShareCG - Share Computer Graphic (CG) Animation, 3D Art and 3D Models
  Privacy Policy