For things like simple filters and comparisons in a where clause, is there any way of representing a location value? For example, something like:
https://data.seattle.gov/rescource/82su-5fxf.json?location='LOCATION (Seattle, 47.612237, -122.290868)'
The documentation mentions that other geographic data can be represented as Well-known Text (WKT) and you can use that in things like simple filters and comparisons, however as far as I can find, there doesn't seem to be a WKT representation of location values.
It's probably intended for users to use things like within_circle
rather than directly comparing the values and I've seen the note on the documentation page that location is a legacy datatype, so it would make sense if there wasn't a way.
I personally would use something like within_circle
in an app, but I'm working on writing a haskell SODA bindings library, so I just want to make it available (although discouraged) if it is possible. I wouldn't want the bindings to prevent a valid call from being made.
My examples will be using the version 2.1 end point rather than the old 2.0 one you link to above, so make sure you're using this verison: https://dev.socrata.com/foundry/data.seattle.gov/3c4b-gdxv
You actually can't do exact equality in a simple filter on a Point
column. The closest approximation I'd recommend is using within_circle
with a very small circle, like this:
GET https://data.seattle.gov/resource/3c4b-gdxv.json?$where=within_circle(location,%2047.514821,%20-122.258635,%2010)
If you're looking for how to format lat/longs in WKT, you'll want to format them as a POINT
I didn't realize it, but that's not actually documented for our Point
datatype, so I'll add that to my queue!
UPDATE: StevenW discovered you can do an exact filter if you get the syntax right:
GET https://data.cityofchicago.org/resource/6zsd-86xi.json?location='POINT (-87.631046 41.694312)'
Note that this requires you to have the EXACT same lat/lon as the point, so it doesn't have much margin for error.