Distance to the nearest train station - google-maps

Using Google Map or any other map provider, if I have a GPS tracking device on a train, how do I get a railway distance between the train to the nearest train station?

If you are physically on the train and have a GPS tracked device, most mapping platforms won't be able to snap you to the railway line unless the device/user is sitting at a station. If the device is close enough to road, usually within 150 meters, it will likely snap to that. If the user was at a station, its much easier and just a matter of calculating a transit route.
That said, most transit data uses straight line distances between stations and not true travel distances. I've worked with many large transit agencies around the world and many of them don't even know where their railway lines run, let along the true distance between stations. What they do know is how long it takes to travel between stations and that's all they generally care about for the most part.
To do this correctly, you will need access to the raw railway line vector data. Open street maps has some, but I don't know how accurate or complete it is. Many agencies or governments publish this data, but often it is just straight lines drawn between stations, so you would have to look and see what's available. Once you have complete data, then you can snap to your GPS point to the nearest railway line then calculate the shortest path along all railway lines to the station in question. This is fairly complex, but I've done this before for both railway lines and private road networks. There are several open source libraries that can assist with this, like this one: https://github.com/perliedman/geojson-path-finder

Related

GIS - connect presence point to closest raster

I am currently trying to run the maxent modelling in R on a dataset of moon jellyfish in the north east Atlantic waters. I have environmental variables datasets from Copernicus ocean monitoring service. Since much of my presence points have a basis in citizen science observations they are mostly in coastal areas. My problem is that the environmental variables doesn’t always reach all the way in to the coast, and especially fjords and bay areas. Therefor some of my analyses give the error: “more than half of the presence points have NA predictor values”. Is there any way to join these presence points that fall outside to the closest raster? I have tried a few commands like approxNA, st_nearest_feature and focal but non of these seem valid in this matter.
Any help in this matter or other tips on working with coastal data in maxent would be highly appreciated!

How to detect the exact geographic location of a site visitor

We have a tool on our travel site which should exactly calculate the distance from the visitor location to a given hotel which is known bye longitude and latitude. To achieve this we use google API but this is not accurate, some time the visitor location is about 40/50 km from the real location. According to other coders is not possible to do better. I can't believe that there is no the possibility to detect the exact geographic location of visitor. I have seen there are some other similar question but those are 2/3 year old.
Thank you
the location of a device can be obtained in two ways, by means of GPS or by means of the approximate location of the IP. The GPS reception can be affected by various factors .. in the cities is of some importance to the Urban Canyonin ie the reflection of the GPS waves on buildings. these factors can lead to an error of several meters and particularly unfavorable circumstances even of some tens of meters .. Another mode of detection is based on the geo-referencing of the IP and on routing that uses the device through wifi networks or data connections in this case the error on the position is normally a few tens of meters ..

Geolocation, map and polygon intersection?

I need to retrieve the latitude and longitude coordinates of the intersection of a polygon with the street (look the blue point on the edge of the circle. image here!!!)
I need this data in order to calculate the road length from center of the circle, to its edge). Does anybody know if this task is possible, and if yes which technology allows for doing that ?
This works only if you have the vector data of all streets. This does not work with an image (jpg bmp).
When you have the vector data, you do a simple circle with line intersection, which you have learned in school.
You might transform the vectors first to a cartesian x,y plane such that you dont use latitude, longitude from the street vectors.
vector data, you can get for free from OpenStreetMap, or from TomTom or NavTeq when it is a huge project. Sometimes the state provides this data, too.
A common data format for such vector data is the ESRI shp file format. (.shp)

Mongodb geospatial index vs GoogleMaps Directions Service

I recently worked on a small project on location-based services and my intention was to locate the nearest cab (GPS fitted) within a given radius of a requesting passenger (GPS enabled Android phone). I wanted to use MongoDB's geospatial indexes, but it turned out that geospatial indexes work on lat-longs and they calculate displacement between two points, not the distance. In my case, search was confined within a city, and I had to go for GoogleMaps Directions Service because it tells the distance as on the road, estimated time taken etc.
Does this mean that geospatial indexes make sense only when displacement is large enough, so that distance and displacement becomes essentially the same?
Geospatial indexes have the goal of having fast data retrieval based on position on a multi-dimensional space. If you have the cab position data in a MongoDB database you could use a geospatial index to fastly select a reduced set of cabs which are more likely to be the closest one, but still you'd have to calculate the distance on the road (and eventually the drive time) using an algorythm on the road network.
For example you know that if the closest (in straight line) cab is at 20km from you (measured through the road), you know that any cab outside the 20km radius will surely be further away (on the road) than the first one you found, so you're not interested in them.
You can then use MongoDB spatial index to get all the cabs in 20km radius and then you can find among them which one has the minimum distance.

GoogleMapApi looses precision depending the country you execute

I'm using http://code.google.com/p/php-google-map-api/. I made an application to get latitude and longitude of different street names. But when I execute this script from outside my country this precision is lost and I can't geolocate all the streets.
I think that Google keeps a different index depending of the country you are. How can I change the country (or locale) of my API?
Once we had an experiment on Mobile Network Development. We used GoogleMaps as basic geolocation tool for mapping/locating and measuring Base Stations characteristics. As the result, we've got into trouble very quickly.
We needed rather precise data (about 5 meters maximum deviation) and what do you think ? The street which was 2 km long (what was measured after experiment with required accuracy) was calculated as 1.7 km in GoogleMaps.
Moreover, most of the patches (ground photos) that are shown on map, overlaps each other in different way. Actually, it depends on country and on the precision of shooting, because some countries are more detailed some are not (very not).
Speaking about streets, this deviation is rather considerable to say that it can be precise. GoogleMaps should not be treated as the precise geolocation tool in any case, especially if high precision is required (street level is already above-normal precision).
So, I propose you not to take into account this data very seriously. Otherwise GoogleMaps is a very nice security breach for all of us. Imagine that You have nuclear bomb or missle and you already know where to direct it with accuracy of several meters, sitting somewhere in the middle of the Sahara. Here you are ...