geo location modeling question

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

geo location modeling question

Will Schenk
I'm trying to put a bunch of things on a map, and I have their
locations stored as lat and long.  If I were to use sql, I'd so
something like

select from locations where lat > min_lat and lat < max_lat and lon >
min_lon and lon < max_lon

I'm not sure how I'd even go about figuring this out with a key/value
store.  Any pointers?

--
Will Schenk
http://www.sublimeguile.com

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: geo location modeling question

John Lynch
Will, check out GeoHashing  http://en.wikipedia.org/wiki/Geohash

Basically it combines the 2 lat lng values into one hash, which when ordered, puts things near to each other in space near to each other in the hash. This is how MongoDB does its geo searching. They, however, have the advantage of an index. Cassandra has the capability to do ordered keys, which would come in handy for this use case. For Riak you would need to figure something out yourself as it doesn't support ordered keys. 

Now that I'm thinking about it, the Geohash looses precision as you drop off characters from the hash, so maybe you could organize it as a tree structure with Riak links. If you were only concerned about a small geographic area that might work.


Regards,

John Lynch, CTO
Rigel Group, LLC
[hidden email]


On Thu, Mar 25, 2010 at 11:35 AM, Will Schenk <[hidden email]> wrote:
I'm trying to put a bunch of things on a map, and I have their
locations stored as lat and long.  If I were to use sql, I'd so
something like

select from locations where lat > min_lat and lat < max_lat and lon >
min_lon and lon < max_lon

I'm not sure how I'd even go about figuring this out with a key/value
store.  Any pointers?

--
Will Schenk
http://www.sublimeguile.com

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: geo location modeling question

Kirill A. Korinskiy
In reply to this post by Will Schenk
At Thu, 25 Mar 2010 14:35:22 -0400,
Will Schenk <[hidden email]> wrote:

>
> I'm trying to put a bunch of things on a map, and I have their
> locations stored as lat and long.  If I were to use sql, I'd so
> something like
>
> select from locations where lat > min_lat and lat < max_lat and lon >
> min_lon and lon < max_lon
>
> I'm not sure how I'd even go about figuring this out with a key/value
> store.  Any pointers?
>

Short answer: no

Long answer: yes, but you must use mapreduce see
http://wiki.basho.com/display/RIAK/MapReduce for more information

--
wbr, Kirill

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: geo location modeling question

Alexander Sicular
In reply to this post by John Lynch
I would second everything John said and also recommend mongo, http://www.mongodb.org/display/DOCS/Geospatial+Indexing, under the 'use the right tool for the job' principle.



On Mar 25, 2010, at 2:53 PM, John Lynch wrote:

> Will, check out GeoHashing  http://en.wikipedia.org/wiki/Geohash
>
> Basically it combines the 2 lat lng values into one hash, which when ordered, puts things near to each other in space near to each other in the hash. This is how MongoDB does its geo searching. They, however, have the advantage of an index. Cassandra has the capability to do ordered keys, which would come in handy for this use case. For Riak you would need to figure something out yourself as it doesn't support ordered keys.  
>
> Now that I'm thinking about it, the Geohash looses precision as you drop off characters from the hash, so maybe you could organize it as a tree structure with Riak links. If you were only concerned about a small geographic area that might work.
>
>
> Regards,
>
> John Lynch, CTO
> Rigel Group, LLC
> [hidden email]
>
>
> On Thu, Mar 25, 2010 at 11:35 AM, Will Schenk <[hidden email]> wrote:
> I'm trying to put a bunch of things on a map, and I have their
> locations stored as lat and long.  If I were to use sql, I'd so
> something like
>
> select from locations where lat > min_lat and lat < max_lat and lon >
> min_lon and lon < max_lon
>
> I'm not sure how I'd even go about figuring this out with a key/value
> store.  Any pointers?
>
> --
> Will Schenk
> http://www.sublimeguile.com
>
> _______________________________________________
> riak-users mailing list
> [hidden email]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
> _______________________________________________
> riak-users mailing list
> [hidden email]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: geo location modeling question

Mårten Gustafson
Or PostGis (GIS extension to PostgreSQL).



/Mårten

On 25 mar 2010, at 19.56, Alexander Sicular <[hidden email]> wrote:

> I would second everything John said and also recommend mongo, http://www.mongodb.org/display/DOCS/Geospatial+Indexing 
> , under the 'use the right tool for the job' principle.
>
>
>
> On Mar 25, 2010, at 2:53 PM, John Lynch wrote:
>
>> Will, check out GeoHashing  http://en.wikipedia.org/wiki/Geohash
>>
>> Basically it combines the 2 lat lng values into one hash, which  
>> when ordered, puts things near to each other in space near to each  
>> other in the hash. This is how MongoDB does its geo searching.  
>> They, however, have the advantage of an index. Cassandra has the  
>> capability to do ordered keys, which would come in handy for this  
>> use case. For Riak you would need to figure something out yourself  
>> as it doesn't support ordered keys.
>>
>> Now that I'm thinking about it, the Geohash looses precision as you  
>> drop off characters from the hash, so maybe you could organize it  
>> as a tree structure with Riak links. If you were only concerned  
>> about a small geographic area that might work.
>>
>>
>> Regards,
>>
>> John Lynch, CTO
>> Rigel Group, LLC
>> [hidden email]
>>
>>
>> On Thu, Mar 25, 2010 at 11:35 AM, Will Schenk <[hidden email]>  
>> wrote:
>> I'm trying to put a bunch of things on a map, and I have their
>> locations stored as lat and long.  If I were to use sql, I'd so
>> something like
>>
>> select from locations where lat > min_lat and lat < max_lat and lon >
>> min_lon and lon < max_lon
>>
>> I'm not sure how I'd even go about figuring this out with a key/value
>> store.  Any pointers?
>>
>> --
>> Will Schenk
>> http://www.sublimeguile.com
>>
>> _______________________________________________
>> riak-users mailing list
>> [hidden email]
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>
>> _______________________________________________
>> riak-users mailing list
>> [hidden email]
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
> _______________________________________________
> riak-users mailing list
> [hidden email]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: geo location modeling question

Justin Sheehy
On Thu, Mar 25, 2010 at 3:33 PM, Mårten Gustafson
<[hidden email]> wrote:

> Or PostGis (GIS extension to PostgreSQL).

Indeed -- in the short term, a GIS-specific system will probably be
your best bet for modeling that kind of data.  However, we have some
real interest in those sorts of problems and we don't plan on staying
out of them in the longer term.

-Justin

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: geo location modeling question

Ben Myles
In reply to this post by John Lynch
I've got a Ruby implementation of what John described that uses Redis.
Doesn't work so well for Riak since it makes heavy use of sorted sets,
but if you're looking for a lightweight implementation you may be
interested. It should scale fairly well but if you're planning on
storing millions of points you'd need to shard across multiple Redis
servers based on a prefix of the geohash. Attached the file.

On Thu, Mar 25, 2010 at 11:53 AM, John Lynch <[hidden email]> wrote:
> Will, check out GeoHashing  http://en.wikipedia.org/wiki/Geohash
...

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

geo_hash_db.rb (2K) Download Attachment