Using Socrata API distance_in_meters() function with separate latitude, longitude field - soql

I am trying to retrieve information about trees surrounding a given location from the Socrata API.
API Endpoint Description
I found two functions within_circle(...) and distance_in_meters(...) which I could use to filter the data set. The problem is, that those functions need either a location or a point data type which is not present in the data set.
There is, however a latitude and longitude field.
Is there any method to utilize those functions or get nearby trees other way?
Tried this, but POINT(0 0) must be the point of the tree.
https://data.cityofnewyork.us/resource/nwxe-4ae8.json?$where=within_circle( 'POINT(0 0)' ,0,0,400)
I need something like this.
https://data.cityofnewyork.us/resource/nwxe-4ae8.json?$where=within_circle( make_point(latitude, longitude) ,0,0,400)
SoQL

If you have not already done so, you may want to submit this question at https://support.socrata.com. In addition to the possibility that the people there will have an answer I do not, it would serve as some feedback that a function like what you had in mind would be useful.
I cannot think of a way to do exactly what you have in mind. Really, what I mean is a way that is within your power (or mine). The owner of the dataset could create a Point column -- and you may want to reach out to the NYC open data team to ask for that if you have not already done so.
However, since the X and Y coordinates, in feet, are present, you should be able to use the Pythagorean theorem to determine the distance from any given point. For that matter, the size of a degree of latitude or longitude cannot vary that much over an area as small as NYC so you could do the same thing with those values and save having to figure out the X and Y of your reference point.
Good luck!
Jon

Related

How to retreive speed limit from here maps given a latitude and longitude?

I'm trying to get speed limit from Here API maps but I can't find the way to do it. I tryed few example on web site but the only one that works is the one which require point of start and point of stop of the route.
I would like to get the speed limit given only one point ( or a box ). Which api do I have to use? Is there an example?
https://route.cit.api.here.com/routing/7.2/calculateroute.json?jsonAttributes=1&waypoint0=51.31854,9.51183&waypoint1=50.11208,8.68342&departure=2019-01-18T10:33:00&routeattributes=sh,lg&legattributes=li&linkattributes=nl,fc&mode=fastest;car;traffic:enabled&app_code=appcode&app_id=appid
This is the waypoint one but is not what I'm looking for, I would like to pass it only a Latitude / Longitude.
Thank you
You can achieve this by using PDE API(Platform Data Extension)
You have to first map your geocordinates(lat,long) to a navigable position(lat,long) for the given coord and the Functional Class(FC1-5) it is located in. This you can achieve by a simple geocoder request
You can calculate tilexy values based on the navigable lat,long and pass it to PDE API for querying speed limit layer on that particular FC class.
Look at https://tcs.ext.here.com/examples/v3/link_speed_locator example which covers this exact usecase.
Below is a sample geocoder request. Here prox parameter is your lat,long
https://reverse.geocoder.cit.api.here.com/6.2/reversegeocode.json?app_id=xxxx&app_code=yyyy&prox=50.133848, 8.715332,500&mode=retrieveAddresses&maxResults=1&additionaldata=SuppressStreetType,Unnamed&locationattributes=linkInfo
Below is a sample pde request
https://pde.cit.api.here.com/1/tiles.json?layers=SPEED_LIMITS_VAR_FC1,SPEED_LIMITS_VAR_FC2,SPEED_LIMITS_VAR_FC3,SPEED_LIMITS_VAR_FC4,SPEED_LIMITS_VAR_FC5,ROAD_GEOM_FC1,ROAD_GEOM_FC2,ROAD_GEOM_FC3,ROAD_GEOM_FC4,ROAD_GEOM_FC5&levels=9,10,11,12,13,9,10,11,12,13&tilexy=536,398,1073,797,2147,1594,4294,3188,8588,6377,536,398,1073,797,2147,1594,4294,3188,8588,6377&app_id=xxxx&app_code=yyyy
Read more about it in the developer site - https://developer.here.com/documentation/platform-data/topics/quick-start-view-map-data.html
Hope you find this useful!
The ReverseGeocoder has rarely used mode "trackPosition" (mode=trackPosition).
In combination with locationattributes=linkInfo you may retrieve the speed limit for that matching road.

Here API: Map NAVTECH edge numbers to latitude/longitude?

I am using the Here API to search for roads where traffic accidents occur in my home town. My aim is to extract the full road coordinates (as sequence of of lat/lons) where the accident is active in order to draw that road on a reasonable scale.
Using the traffic/6.1/incidents API, I query for the data using a geographical bounding box. An accident in the response is described by one pair of TMC locations as well as one pair of lat/lon geographical points. This data is too coarse-grained for plotting the roadway. (Please correct me if I am wrong here, but I would like to add some more detail about turns of the road.)
My question regards what I found when I turned to examine the rest of the accident/incident response, containing so-called NAVTECH data on this (XML) form:
<NAVTECH><EDGE><EDGE_ID>1150578390</EDGE_ID><EDGE_ID>1150578391</EDGE_ID>
<EDGE_ID>...</EDGE_ID>
<VERSION_ID>201604</VERSION_ID></NAVTECH>
My question is: Is there any available method to map the NAVTECH edges to pairs of lat/lon coordinates?
I have searched Here.com, the here-api stackoverflow tag and tried to Google for an answer, but I find so little documentation on this type of data. I am looking for all information I can find to (i) Describe the NAVTECH edges and their meaning, (ii) How to map NAVTECH to geographical coordinates. In general, (iii) Can I use the Here API to get more geographical information than this about roads where there are accidents?
Kind regards,
Vilhelm from Sweden
You can pass a lat/lon to their routing API and get back the shape point coordinates (and other attributes) for the road edge at that location, like this:
https://route.cit.api.here.com/routing/7.2/getlinkinfo.xml?waypoint=43.066628,-71.471729&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&linkattributes=all
Unfortunately, though, this may not be a long term solution, as seaBass states here:
getlinkinfo will depreciated March 31, 2017. In order to get speed limit information you will have to use PDE (Platform Data Extension) which requires an APP ID and Code

Find cities within one hour from my location

I want to use some Google API to find a list of places within one hour from my location. I've found Google Maps Distance Matrix API but it only gives you the distance between places you specify.
What I really want to do is to paint an area in a map, I don't really need the list of places.
If I can't query by time maybe I can deal with distance (which is probably easier)
Thanks a lot!!

Maps API 3 Directions with fuzzy via co-ordinates

I have a number of GPS co-ordinates that describe a route. My intention is to draw a polyline along the route, and then colour segments based on some data I have.
Problem is, the GPS coordinates can occur on the roadside either side of main roads. When using the obvious Directions service solution a lot of "back and forth" occurs as Google tries to get me either side of a split lane road
What I am aiming for is a direct route from A-H passing through every way point. I have considered reverse geocoding the coordinates to a street name and having the directions use the street as a way point, but that picks a specific point on the street that may not be related to the actual route. Single polylines are also not an option as some routes have turns in them.
Is there a way to 'fuzzy' my waypoints so that the directions are happy when passing within a certain radius of the points? If not, has anyone got any other solutions?
Thanks heaps.
Edit: It's also not an option to just not use the middle way points because sometimes the path is not optimal.
Also have tried my own fuzzy coords now, by +- some small value to each consecutive lat/lng pair. Unsurprisingly I ran into OVER_QUERY_LIMIT pretty soon.

Create directions on a map based on custom data

So what I'm trying to do is the following:
Have a map (such as Google Maps or questMaps). It doesn't matter at all which API I need to use.
On that map have an overlay on the streets. So say (for example) the street has bad lightning at night, it will be colored red. If it has good lightning it will have a green overlay.
Based on the overlay the map creates a custom route (for example the user only wants to walk on the green/well lit streets).
I have no idea how to accomplish this (especially step 3).
First, you'll have to decide what data you need. How do you categorize certain streets as lit or unlit? What if some parts of a street are well lit and some have no lights? Do you need to know the location of every streetlight in your area? What if lights burn out?
After figuring out what data you need, you need to build your dataset. I'd be VERY surprised if this data already exists, so you will probably need to gather it yourself. Either go around town and take notes, or crowdsource the project, or figure out some other way.
Once you have gathered your data, learn the drawing API of whatever mapping tool you wish to use. They all should have functions in their API for drawing colored lines (for streets) or points (for streetlights) on top of an existing map.
Finally, learn the navigational API of the mapping tool you chose. You're right, this is a hard step. I know Google Maps lets you specify certain waypoints when requesting directions; maybe your app can calculate well-lit waypoints and feed them to Google Maps' Directions service to influence the route it generates.
Good luck!
For custom routing, you need to read up on "Graph Theory". This ignores the geography of the street map, and considers it as a set of junctions (nodes or vertices in the graph theory jargon) connected by edges. You can assign weights to edges - these could be lengths, travel times, ones and zeroes etc. Anything. They can have no relation to the position on the map.
So for your application, you'd assign a large weight to unlit streets, and a small weight to lit streets, then use a standard minimum-weight algorithm to get a route from one node to another.

Resources