Finding Lat-Long from shp file

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Finding Lat-Long from shp file

Mukul Gupta-3
hi...
I want to know if there is any method to automatically get the lat long of the particular point in the shape file and then store the corresponding values in mysql database file.
Regards
Mukul

_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

RE: Finding Lat-Long from shp file

Venkat Rao Tammineni

Hi,

 

    mapObj will have  extents property ,where you can get  your map extents…

 

For example :- Alert(Map.extent.minx);

Thanks,

 

Venkat

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mukul Gupta
Sent: Tuesday, April 28, 2009 5:39 PM
To: [hidden email]
Subject: [mapserver-users] Finding Lat-Long from shp file

 

hi...
I want to know if there is any method to automatically get the lat long of the particular point in the shape file and then store the corresponding values in mysql database file.
Regards
Mukul


_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

RE: Finding Lat-Long from shp file

Mohammed Rashad
In reply to this post by Mukul Gupta-3
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

_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

RE: RE: Finding Lat-Long from shp file

Fawcett, David (MNIT)
Message
You could also write a fairly simple python script using the gdal/ogr python modules.
-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Mohammed Rashad
Sent: Tuesday, April 28, 2009 12:17 PM
To: [hidden email]
Subject: [mapserver-users] RE: Finding Lat-Long from shp file

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

_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users