[mapserver-users] RE: Finding Lat-Long from shp file

Mohammed Rashad rashadkm at gmail.com
Tue Apr 28 13:17:11 EDT 2009


Hi,

Here is the way you can find lat-long values from shp files. The method is
ugly.
I used this method to select lat-long values from a shape file consisting of
about 150 records. Using this method all lat-long values from a shapefile
consisting of place names of country can be selected and saved into files.
I already told method is dirty.

You can find using postgreSQL. first you should install postgis-postgresql
package.
and follow instructions in postgis manual.
you want to import some files after installing postgis such as lwpostgis.sql
etc...

I think you added necessary attributes in shape files such as name of place
etc,..

create a database in postgresql with postgis enabled (say db1)
Now import .shp files into postgresql using cmd:

you should have a database db1 with postgis support.
shp2pgsql /root/vect1.shp vect1 db1 > /root/vect1.sql

now you got vect1.sql file

import sql file into postgresql.
psql -d db1 -f /root/vect1.sql

Now logon to postgresql admin tool such as phppgadmin or you can do these
thing from postgresql interactive terminal.

In the database db1 now you have another table name vect1.
vect1 has some other attributes such as gid,the_geom etc..  other than
attributes you have entered.   'the_geom' is the geometry of shape file.

select X(the_geom) from vect1; query executes to display longitude all
entries in shape files

and

select Y(the_geom) from vect1; query executes to display latitude all
entries in shape files


this data can also be inserted into table by inserting a new column for
latitude and longitude.

If you want table back to shp files using the cmd:
pgsql2shp -f vect1 -p 5432 db1 vect1

Or

You can also export column  latitude and longtiude into mysql also as you
wish


-- 
Regards,
Mohammed Rashad K.M
http://keralainfo.web4all.in/
+919605476742
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090428/815833a7/attachment-0001.html


More information about the mapserver-users mailing list