![]() > GEODIST bigfoot:sightings:locations report:40120 report:12140 km > GEODIST bigfoot:sightings:locations report:40120 report:12140 m ![]() feet and miles), you can just specify which you want at the end of the command: If you’re not interested in meters and prefer kilometers or Freedom Units (i.e. Just hand GEODIST a key and two members and it will tell you how far apart they are in meters. > GEODIST bigfoot:sightings:locations report:40120 report:12140 You can find out with the GEODIST command: Maybe you want to determine the distance between a couple of Bigfoot sightings. You might want to do something a little more sophisticated. That’s an artifact of how they are stored and is something we’ll talk about in a bit: 1) 1) "-89.15173262357711792"Īgain, note that the two sets of coordinates returned are longitude first and then latitude. This will return the coordinates with, perhaps, a bit more precision than they were entered with. > GEOPOS bigfoot:sightings:locations report:40120 report:12140 You can also query for members variadicly: > GEOPOS bigfoot:sightings:locations report:40120 If you just want to pull out the coordinates you can use the GEOPOS command: But what about reading and querying? There are several ways to do this. There isn’t a way to find them by report number, but it is part of the link so you can probably figure it out.Īnyhow, that covers creating and updating. ![]() You can also look them up from their original source on the Bigfoot Field Researchers Organization’s website. ![]() If you’re playing along at home you can look them up with these commands: We’ve upserted a Bigfoot sighting in southern Illinois and one just west of Chicago. If you’re like a lot of people, your instinct will be to enter the latitude first. Note: The longitude and latitude are presented in the command in that order. GEOADD is a variadic command as you can also upsert multiple members. Another pattern you’ll see repeatedly is the variadic command-a command that takes a variable number of arguments. Note: This type of operation is called an upsert-a portmanteau of update and insert-and is a popular pattern in Redis. If it does, its location will be updated. If the member doesn’t exist, it will be inserted. This command asks Redis to add or update a member named report:40120 to the Geo Set bigfoot:sightings:locations at longitude -89.15173 and latitude 37.61335. Adding and updating members to this set is easy. It holds a named set of locations on the globe. The straightforward bitsĪ Geo Set is the key data structure for working with geospatial data in Redis. Of course, you’ll need an install of Redis as well. If you want to load the data up and play along, I’ve set up a repository with the data, the code to transform it, and instructions on running it. Today, we’ll be playing with just the longitude, the latitude, and the report number of the Bigfoot sightings. Class C : Someone told me they saw Bigfoot.Class B : I found evidence of Bigfoot, like a footprint or bit of fur.It’s not relevant to what we are doing today-I’m sharing this just for the fun of it- but here are the three classes of Bigfoot sightings: The classification is my favorite bit although the accounts are fun to read, too! Each row is an account of a Bigfoot sighting and includes the full text of the account, when it happened, and even a classification. The Bigfoot dataset has lots of great stuff in it. And, since I can’t write a blog post without a fun theme for my examples, this time I’m going to be using my favorite dataset of all: Bigfoot sightings. Redis’ geospatial data structures are fairly straightforward to work with but have some interesting nooks and crannies. Since I thought it was cool, I thought y’all might as well. I think one of the coolest features of Redis-one that surprised me when I discovered it-is the geospatial data structure.
0 Comments
Leave a Reply. |