Using PostGIS for latitude & longitude

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

Using PostGIS for latitude & longitude

nevillekb

I have a table in postgresql 9.2 that stores the latitude and longitude of locations as integer values.

I intend to do something like when a user searches for a location, he also gets information on other locations that are within a 7 mile radius of that searched location.

How do i use postGIS for this since i am new to it. Any idea.?
Reply | Threaded
Open this post in threaded view
|

Re: Using PostGIS for latitude & longitude

James David Smith
Dear Neville,

I would first start with making a proper 'geometry' column rather than
using your Lat and Long columns. You would do this with code like
this:

SELECT AddGeometryColumn ('table_name','the_geom',27700,'POINT',2);

Notes about this:

'the_geom' is an arbitrary column name. Call it what you like.
27700 is the SRID of your data. If you are working with data in WGS84
then it would be replaced with the value 4326
'POINT' defines the type of geometry that is being stored. This could
be 'LINESTRING' or 'LINE' etc.
2 is the dimensions.

Once you have a geometry column, you might then populate it with data
from your latitude and longitude columns by doing this:

UPDATE table_name
SET the_geom = st_makepoint("longitude", "latitude");

Thanks

James

On 19 December 2012 09:51, nevillekb <[hidden email]> wrote:

>
> I have a table in postgresql 9.2 that stores the latitude and longitude of
> locations as integer values.
>
> I intend to do something like when a user searches for a location, he also
> gets information on other locations that are within a 7 mile radius of that
> searched location.
>
> How do i use postGIS for this since i am new to it. Any idea.?
>
>
>
>
> --
> View this message in context: http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> [hidden email]
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Using PostGIS for latitude & longitude

Nicolas Ribot-2
In reply to this post by nevillekb
Hi,

You could create a geometric column storing points based on coordinates, then use a spatial query to also include near locations.

Recent threads on this list can give you hints:
   • on creating a geographic column based on lat long values
   • on using st_dwithin or nearest neighbor to find locations 7 miles apart.

Nicolas


On 19 December 2012 10:51, nevillekb <[hidden email]> wrote:

I have a table in postgresql 9.2 that stores the latitude and longitude of
locations as integer values.

I intend to do something like when a user searches for a location, he also
gets information on other locations that are within a 7 mile radius of that
searched location.

How do i use postGIS for this since i am new to it. Any idea.?




--
View this message in context: http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


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

Re: Using PostGIS for latitude & longitude

Brent Wood
In reply to this post by nevillekb
Hi Neville,

Obviously you start by installing Postgis in your database.

Follow the instructions for your Postgis version & operating system.

To create your geometry:

1. add a geometry column to your table. This will be a point type, with a SRID of 4326 (ie: lat long degrees - see http://www.spatialreference.org/ref/epsg/4326/
See here for the command to use:
http://postgis.refractions.net/docs/AddGeometryColumn.html

2. Populate this column (called geom, for example), from your lat, lon columns with:
update table set geom=ST_SetSRID(ST_MakePoint(lon,lat),4326);
as described at http://www.postgis.org/docs/ST_MakePoint.html


You then need to make your query to retrieve the points with 7 miles of a specified location. This can get complicated depending on how accurate you want to be. The distance of 1 degree for your latitudes is 60 nautical miles. For longitude, it is 60 nm at the equator & decreases proportional to the cosine of the latitude for non-equatorial values. Postgis allows you to reproject your coordinates, or calculate against a sphere, or a selected spheroid (given the Earth is not spherical). I'm assuming here that a spherical calculation will work in your case, using 1/60th of a degree = 1 mile.

given a user location of $x,$y, you need to construct a point geometry & check the distance (measured on a sphere in units degrees) against each of your points, eg:
select * from table where ST_Distance_Sphere(ST_MakePoint($x,$y),geom) <= 7/60;

see: http://postgis.refractions.net/documentation/manual-1.4/ST_Distance_Sphere.html

HTH,

  Brent Wood



--- On Wed, 12/19/12, nevillekb <[hidden email]> wrote:

From: nevillekb <[hidden email]>
Subject: [postgis-users] Using PostGIS for latitude & longitude
To: [hidden email]
Date: Wednesday, December 19, 2012, 10:51 PM


I have a table in postgresql 9.2 that stores the latitude and longitude of
locations as integer values.

I intend to do something like when a user searches for a location, he also
gets information on other locations that are within a 7 mile radius of that
searched location.

How do i use postGIS for this since i am new to it. Any idea.?




--
View this message in context: http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

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

Re: Using PostGIS for latitude & longitude

Duncan Golicher
You can get accurate distances in meters simply by casting to geography.

http://www.postgis.org/docs/ST_Distance.html

This works with ST_DWithin as well in the where clause. Just makes queries a bit slower. To cast geometry to geography use the :: operator.

Duncan





On Wed, Dec 19, 2012 at 11:08 AM, <[hidden email]> wrote:
Hi Neville,

Obviously you start by installing Postgis in your database.

Follow the instructions for your Postgis version & operating system.

To create your geometry:

1. add a geometry column to your table. This will be a point type, with a SRID of 4326 (ie: lat long degrees - see http://www.spatialreference.org/ref/epsg/4326/
See here for the command to use:
http://postgis.refractions.net/docs/AddGeometryColumn.html

2. Populate this column (called geom, for example), from your lat, lon columns with:
update table set geom=ST_SetSRID(ST_MakePoint(lon,lat),4326);
as described at http://www.postgis.org/docs/ST_MakePoint.html


You then need to make your query to retrieve the points with 7 miles of a specified location. This can get complicated depending on how accurate you want to be. The distance of 1 degree for your latitudes is 60 nautical miles. For longitude, it is 60 nm at the equator & decreases proportional to the cosine of the latitude for non-equatorial values. Postgis allows you to reproject your coordinates, or calculate against a sphere, or a selected spheroid (given the Earth is not spherical). I'm assuming here that a spherical calculation will work in your case, using 1/60th of a degree = 1 mile.

given a user location of $x,$y, you need to construct a point geometry & check the distance (measured on a sphere in units degrees) against each of your points, eg:
select * from table where ST_Distance_Sphere(ST_MakePoint($x,$y),geom) <= 7/60;

see: http://postgis.refractions.net/documentation/manual-1.4/ST_Distance_Sphere.html

HTH,

  Brent Wood



--- On Wed, 12/19/12, nevillekb <[hidden email]> wrote:

From: nevillekb <[hidden email]>
Subject: [postgis-users] Using PostGIS for latitude & longitude
To: [hidden email]
Date: Wednesday, December 19, 2012, 10:51 PM



I have a table in postgresql 9.2 that stores the latitude and longitude of
locations as integer values.

I intend to do something like when a user searches for a location, he also
gets information on other locations that are within a 7 mile radius of that
searched location.

How do i use postGIS for this since i am new to it. Any idea.?




--
View this message in context: http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

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




--
Dr Duncan Golicher
Investigador Titular,
El Colegio de la Frontera Sur, Chiapas,Mexico
Mexico tel +52 1 967 137 94 20
Skype name duncangolicher

Publications: http://www.mendeley.com/profiles/duncan-golicher

Senior lecturer, Bournemouth University, UK
Centre for Conservation Ecology & Environmental Change
School of Applied Sciences
Christchurch House rm C218a
Bournemouth University
Fern Barrow
Poole (Dorset) BH12 5BB UK
Tel. +44 (0)1202 961682

For list of publications see Researcher ID:
http://www.researcherid.com/rid/B-4240-2009

[hidden email]
[hidden email]

Researcher ID:
http://www.researcherid.com/rid/B-4240-2009


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

Re: Using PostGIS for latitude & longitude

nevillekb
A whole hearted thanks to - James, Nicolas, Duncan, pcreso.

Thanks soo much all of you for clearing out my doubts and such a wonderful explanation on how to go about with it..!!

Much Apreciated!

Neville.
Reply | Threaded
Open this post in threaded view
|

Re: Using PostGIS for latitude & longitude

nevillekb
In reply to this post by Brent Wood
Hi,

So i created a table named zipcode with the following columns

Id
State
Zip
Latitude
Longitude
column1
column2

columns named column1 and column2 are the 2 geometry columns i have created to store the lat and long in 2 formats -SRID 4269 (Lat/Lon) and SRID 2163 (US National Atlas – meters).

Then i execute the following query to populate both the columns with the lat and lon data

UPDATE zipcode SET column1 = ST_SetSRID(ST_MakePoint("longitude","latitude"),4269), column2 = ST_Transform(ST_SetSRID(ST_MakePoint("longitude","latitude"),4269), 2163);

Everything has worked fine till now, but now when i try to execute the following query to show all records that are within 5 miles of a given point i get an error.

Query:

select state from zipcode where DISTANCE(column2, ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;

Error Generated:

WARNING  ] select state from zipcode where DISTANCE(column2, ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000
            ERROR:  function st_setsrid(unknown, integer) is not unique
            LINE 1: select state from zipcode where DISTANCE(column2, ST_SetSRID...
                                                                      ^
            HINT:  Could not choose a best candidate function. You might need to add explicit type casts.

Can someone help me out as to where am i going wrong in the above query??

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Using PostGIS for latitude & longitude

Nicolas Ribot-2
Hi,

You have to cast the textual representation of the geometry into an actual geometry, in the st_setSRID function, to resolve the ambiguity:

select state 
from zipcode 
where st_DISTANCE(column2,
ST_SetSRID('POINT(33.911404 -116.768347)'::geometry, 2163)) < 8000;

Nicolas


On 24 December 2012 13:32, nevillekb <[hidden email]> wrote:
Hi,

So i created a table named zipcode with the following columns

Id
State
Zip
Latitude
Longitude
column1
column2

columns named column1 and column2 are the 2 geometry columns i have created
to store the lat and long in 2 formats -SRID 4269 (Lat/Lon) and SRID 2163
(US National Atlas – meters).

Then i execute the following query to populate both the columns with the lat
and lon data

UPDATE zipcode SET column1 =
ST_SetSRID(ST_MakePoint("longitude","latitude"),4269), column2 =
ST_Transform(ST_SetSRID(ST_MakePoint("longitude","latitude"),4269), 2163);

Everything has worked fine till now, but now when i try to execute the
following query to show all records that are within 5 miles of a given point
i get an error.

Query:

select state from zipcode where DISTANCE(column2,
ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;

Error Generated:

WARNING  ] select state from zipcode where DISTANCE(column2,
ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000
            ERROR:  function st_setsrid(unknown, integer) is not unique
            LINE 1: select state from zipcode where DISTANCE(column2,
ST_SetSRID...
                                                                      ^
            HINT:  Could not choose a best candidate function. You might
need to add explicit type casts.

Can someone help me out as to where am i going wrong in the above query??

Thanks



--
View this message in context: http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097p5002125.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


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

Re: Using PostGIS for latitude & longitude

nevillekb
Many Thanks Nicolas!!!!!!
Reply | Threaded
Open this post in threaded view
|

Re: Using PostGIS for latitude & longitude

Brent Wood
In reply to this post by nevillekb
Hi Neville,

Merry Christmas (it already is here in NZ :-)

You are passing a string - 'POINT(33.911404 -116.768347)' - not a geometry in your query hence the error message that ST_SetSRID() doesn't know what the first parameter is

Instead of:

select state from zipcode where DISTANCE(column2,
ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;

try:

select state from zipcode where DISTANCE(column2,
ST_SetSRID(ST_MAKEPOINT(33.911404 -116.768347), 2163)) < 8000;


Cheers,

  Brent


--- On Tue, 12/25/12, nevillekb <[hidden email]> wrote:

From: nevillekb <[hidden email]>
Subject: Re: [postgis-users] Using PostGIS for latitude & longitude
To: [hidden email]
Date: Tuesday, December 25, 2012, 1:32 AM

Hi,

So i created a table named zipcode with the following columns

Id
State
Zip
Latitude
Longitude
column1
column2

columns named column1 and column2 are the 2 geometry columns i have created
to store the lat and long in 2 formats -SRID 4269 (Lat/Lon) and SRID 2163
(US National Atlas – meters).

Then i execute the following query to populate both the columns with the lat
and lon data

UPDATE zipcode SET column1 =
ST_SetSRID(ST_MakePoint("longitude","latitude"),4269), column2 =
ST_Transform(ST_SetSRID(ST_MakePoint("longitude","latitude"),4269), 2163);

Everything has worked fine till now, but now when i try to execute the
following query to show all records that are within 5 miles of a given point
i get an error.

Query:

select state from zipcode where DISTANCE(column2,
ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;

Error Generated:

WARNING  ] select state from zipcode where DISTANCE(column2,
ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000
            ERROR:  function st_setsrid(unknown, integer) is not unique
            LINE 1: select state from zipcode where DISTANCE(column2,
ST_SetSRID...
                                                                      ^
            HINT:  Could not choose a best candidate function. You might
need to add explicit type casts.

Can someone help me out as to where am i going wrong in the above query??

Thanks



--
View this message in context: http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097p5002125.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
postgis-users@...
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

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

Re: Using PostGIS for latitude & longitude

Stephen Woodbridge
Also, be aware that PostGIS expects coordinates in X-Y order which means
for need to enter lat, lon as (long, lat) to correspond to (X, Y).

-Steve

PS: Merry Christmas Brent and everyone else!

On 12/24/2012 3:54 PM, [hidden email] wrote:

> Hi Neville,
>
> Merry Christmas (it already is here in NZ :-)
>
> You are passing a string - 'POINT(33.911404 -116.768347)' - not a
> geometry in your query hence the error message that ST_SetSRID() doesn't
> know what the first parameter is
>
> Instead of:
>
> select state from zipcode where DISTANCE(column2,
> ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;
>
> try:
>
> select state from zipcode where DISTANCE(column2,
> ST_SetSRID(ST_MAKEPOINT(33.911404 -116.768347), 2163)) < 8000;
>
>
> Cheers,
>
>    Brent
>
>
> --- On *Tue, 12/25/12, nevillekb /<[hidden email]>/* wrote:
>
>
>     From: nevillekb <[hidden email]>
>     Subject: Re: [postgis-users] Using PostGIS for latitude & longitude
>     To: [hidden email]
>     Date: Tuesday, December 25, 2012, 1:32 AM
>
>     Hi,
>
>     So i created a table named zipcode with the following columns
>
>     Id
>     State
>     Zip
>     Latitude
>     Longitude
>     column1
>     column2
>
>     columns named column1 and column2 are the 2 geometry columns i have
>     created
>     to store the lat and long in 2 formats -SRID 4269 (Lat/Lon) and SRID
>     2163
>     (US National Atlas – meters).
>
>     Then i execute the following query to populate both the columns with
>     the lat
>     and lon data
>
>     UPDATE zipcode SET column1 =
>     ST_SetSRID(ST_MakePoint("longitude","latitude"),4269), column2 =
>     ST_Transform(ST_SetSRID(ST_MakePoint("longitude","latitude"),4269),
>     2163);
>
>     Everything has worked fine till now, but now when i try to execute the
>     following query to show all records that are within 5 miles of a
>     given point
>     i get an error.
>
>     Query:
>
>     select state from zipcode where DISTANCE(column2,
>     ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;
>
>     Error Generated:
>
>     WARNING  ] select state from zipcode where DISTANCE(column2,
>     ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000
>                  ERROR:  function st_setsrid(unknown, integer) is not unique
>                  LINE 1: select state from zipcode where DISTANCE(column2,
>     ST_SetSRID...
>                                            ^
>                  HINT:  Could not choose a best candidate function. You
>     might
>     need to add explicit type casts.
>
>     Can someone help me out as to where am i going wrong in the above
>     query??
>
>     Thanks
>
>
>
>     --
>     View this message in context:
>     http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097p5002125.html
>     Sent from the PostGIS - User mailing list archive at Nabble.com.
>     _______________________________________________
>     postgis-users mailing list
>     [hidden email]
>     http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
>
> _______________________________________________
> postgis-users mailing list
> [hidden email]
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>

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

Re: Using PostGIS for latitude & longitude

Tim-Hinnerk Heuer

Merry Xmas everyone.

I believe you can also use ST_GeomFromText('POINT(123, 456)', 2163) to get back a geometry.

Regards,
Tim

On Dec 25, 2012 10:30 AM, "Stephen Woodbridge" <[hidden email]> wrote:
Also, be aware that PostGIS expects coordinates in X-Y order which means for need to enter lat, lon as (long, lat) to correspond to (X, Y).

-Steve

PS: Merry Christmas Brent and everyone else!

On 12/24/2012 3:54 PM, [hidden email] wrote:
Hi Neville,

Merry Christmas (it already is here in NZ :-)

You are passing a string - 'POINT(33.911404 -116.768347)' - not a
geometry in your query hence the error message that ST_SetSRID() doesn't
know what the first parameter is

Instead of:

select state from zipcode where DISTANCE(column2,
ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;

try:

select state from zipcode where DISTANCE(column2,
ST_SetSRID(ST_MAKEPOINT(33.911404 -116.768347), 2163)) < 8000;


Cheers,

   Brent


--- On *Tue, 12/25/12, nevillekb /<[hidden email]>/* wrote:


    From: nevillekb <[hidden email]>
    Subject: Re: [postgis-users] Using PostGIS for latitude & longitude
    To: [hidden email]
    Date: Tuesday, December 25, 2012, 1:32 AM

    Hi,

    So i created a table named zipcode with the following columns

    Id
    State
    Zip
    Latitude
    Longitude
    column1
    column2

    columns named column1 and column2 are the 2 geometry columns i have
    created
    to store the lat and long in 2 formats -SRID 4269 (Lat/Lon) and SRID
    2163
    (US National Atlas – meters).

    Then i execute the following query to populate both the columns with
    the lat
    and lon data

    UPDATE zipcode SET column1 =
    ST_SetSRID(ST_MakePoint("longitude","latitude"),4269), column2 =
    ST_Transform(ST_SetSRID(ST_MakePoint("longitude","latitude"),4269),
    2163);

    Everything has worked fine till now, but now when i try to execute the
    following query to show all records that are within 5 miles of a
    given point
    i get an error.

    Query:

    select state from zipcode where DISTANCE(column2,
    ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;

    Error Generated:

    WARNING  ] select state from zipcode where DISTANCE(column2,
    ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000
                 ERROR:  function st_setsrid(unknown, integer) is not unique
                 LINE 1: select state from zipcode where DISTANCE(column2,
    ST_SetSRID...
                                           ^
                 HINT:  Could not choose a best candidate function. You
    might
    need to add explicit type casts.

    Can someone help me out as to where am i going wrong in the above
    query??

    Thanks



    --
    View this message in context:
    http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097p5002125.html
    Sent from the PostGIS - User mailing list archive at Nabble.com.
    _______________________________________________
    postgis-users mailing list
    [hidden email]
    http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users



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


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

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

Re: Using PostGIS for latitude & longitude

nevillekb
In reply to this post by Brent Wood
Thanks for the helpful reply!! and Wishing You A Merry Christmas Too Brent.. :)

Cheers,

Neville.
Reply | Threaded
Open this post in threaded view
|

Re: Using PostGIS for latitude & longitude

nevillekb
In reply to this post by Stephen Woodbridge
Thanks for the reply Stephen!! Merry Christmas..:)
Reply | Threaded
Open this post in threaded view
|

Re: Using PostGIS for latitude & longitude

nevillekb
In reply to this post by Tim-Hinnerk Heuer
Thanks for the reply Tim. Merry Christmas!! :)
Reply | Threaded
Open this post in threaded view
|

Re: Using PostGIS for latitude & longitude

nevillekb
In reply to this post by Brent Wood
Hi Brent,

So at the moment i am hard-coding sample lat and long values to test the functionality and it works!!!

What i wanted to ask is how can i get these values from Google maps and then feed them in my DB rather then hard-coding them. Any idea how to go about?

Thanks,

Neville.
Jo
Reply | Threaded
Open this post in threaded view
|

Re: Using PostGIS for latitude & longitude

Jo
If you get the coordinates in a url, you can extract them with a regular expression.

Instead of using Googlemaps, you could also consider using Openstreetmap data. Investigate the Overpass API. I think it does what you are trying to achieve. You get access to the raw data. The advantage is that if some of your POIs are not present yet, you can easily add them. All you have to do is credit OSM, if you decide to do that.

Cheers,

Jo

2012/12/28 nevillekb <[hidden email]>
Hi Brent,

So at the moment i am hard-coding sample lat and long values to test the
functionality and it works!!!

What i wanted to ask is how can i get these values from Google maps and then
feed them in my DB rather then hard-coding them. Any idea how to go about?

Thanks,

Neville.



--
View this message in context: http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097p5002155.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


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

Re: Using PostGIS for latitude & longitude

Brent Wood
In reply to this post by nevillekb
Neville,

I don't use 'Google maps. I'm unable to provide Google with an in perpetuity licence for my data, so cannot comply with their terms of service.

I also need a web mapping engine that can display polar data & support projections, neither of which Google can.

I have used OpenLayers with Open Street Map (OSM) data instead of Google Maps. Generally a quite acceptable & more flexible/powerful (but more complex) alternative.

So sorry, I can't help with the Google API to get your data onto a Google map.

Cheers,

  Brent Wood



> 2012/12/28 nevillekb <[hidden email]>
>
> Hi Brent,
>
> So at the moment i am hard-coding sample lat and long values to test the
> functionality and it works!!!
>
> What i wanted to ask is how can i get these values from Google maps and then
> feed them in my DB rather then hard-coding them. Any idea how to go about?
>
> Thanks,
>
> Neville.






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

Re: Using PostGIS for latitude & longitude

Stephen Woodbridge
In reply to this post by nevillekb
On 12/28/2012 1:59 AM, nevillekb wrote:
> Hi Brent,
>
> So at the moment i am hard-coding sample lat and long values to test the
> functionality and it works!!!
>
> What i wanted to ask is how can i get these values from Google maps and then
> feed them in my DB rather then hard-coding them. Any idea how to go about?

Aside for the legal issues that might be involved based on the Google
Terms of Service. You might consider using OpenLayers the pulling in a
base map from Bing, OpenStreetMap or Google then setup OpenLayers to
allow you to click on the map and issue an ajax call to a snippet of PHP
code that connects to the database and inserts your coordinate.

This is a pattern that is commonly used for creating and editing
features in a database. In fact you can setup TinyOWS of GeoServer to
act as a WFS-T server that OpenLayers can talk directly to that will
manage all your features in a database table.

-Steve

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