How to get lat-long values of all areas in a city - geocoding

I have tried to find a lot over the Internet but I am unable to get a perfect utility/API for my requirement.
I am interested in getting the latitude, longitude values of all areas in a city.
Currently i am using this google maps api
https://developers.google.com/maps/documentation/geocoding/start
But, when i enter a city name, it is giving only one lat-long pair for that city. Is there any way that if i give a city name, i can get all the areas and their corresponding latitude, longitude values?
Thanks.

There's a nice documentation for this at: Places API
I used this to get the latitude / longitude for one of my own projects and I also have an example of this.
If you look at the example, you can just type a location and it will immediately get the lat / long of the location and zoom in, you can also do this for more locations at the same time. Remember there is a limit for the maps api so it can only process so many data at the same time. Hope this may help you out! :)

Related

Mapbox Geocoding API V5- Get all neighborhoods in a city

Is there a way to get all neighborhoods per city by lat and lng from mapbox API V5.
For example, if I search using the lat and lng of Long Beach.
-118.1937, 33.7701
I expect to get back all the neighborhoods, instead, I only get back one result of
"place_name: "Downtown, Long Beach, California 90802, United States""
I have changed the response limit and bound box, with no results.
Here is the mapbox playground.
https://www.mapbox.com/api-playground/#/forward-geocoding
Thanks!
Mapbox doesn't really do neighborhoods, they require some sort of search data to pull either addresses or places.
However, there are services where you can get neighborhood data. I found this Stack Overflow question to have several links (sadly, most of them outdated....), with the reference to Zillow having a lot of promise.
I'd also suggest the Census Bureau data as it may have what you are looking for, but it is what I would call 'less than user friendly' to find anything - unless you are comfortable reading government spec sort of things... :)

Am I missing the correct geographic/coordinate information from Twitter API?

There are a number of geo-related information when extracting information from Twitter API. Here is part of my codes...
placeHolder = []
placeHolder.append(tweet.author.name.encode('utf8'))
placeHolder.append(tweet.place)
placeHolder.append(tweet.user.location.encode('utf8'))
placeHolder.append(tweet.user.time_zone)
placeHolder.append(tweet.geo)
placeHolder.append(tweet.coordinates)
I have some specific questions hoping to get the answers here:
1) Am I collecting the right geographic location information? Esp. with tweet.geo and tweet.coordinates. Or is there any geographic information I am missing from my codes?
2) Which geo variable should I use to locate where the users published their tweets? "geo" or "coordinates"? Some people said "geo" is out-of-date, but when I look at them in the data, they are simply the same except the longitude and latitude flipped around.
3) I just looked at my data, it seems only about 0.35% of my sample tweets contain information on the "geo"/"coordinates" variable, is it too low or around normal? I found that "tweet.user.location" has way more information, but not standardized, what is the best way to incorporate all of these geo information?
1) Am I collecting the right geographic location information? Esp. with tweet.geo and tweet.coordinates. Or is there any geographic information I am missing from my codes?
Assuming by right geographic location being where the person was at the time of tweet then tweet.place, tweet.geo, and tweet.coordinates are what you're looking for. Anyone under user.* is defined by the user not twitter.
2) Which geo variable should I use to locate where the users published their tweets? "geo" or "coordinates"? Some people said "geo" is out-of-date, but when I look at them in the data, they are simply the same except the longitude and latitude flipped around.
For that one I would also recommend tweet.coordinates for two reasons: a) it's the official geocoded field according to twitter, b) it's in proper geojson format (long, lat)
3) I just looked at my data, it seems only about 0.35% of my sample tweets contain information on the "geo"/"coordinates" variable, is it too low or around normal? I found that "tweet.user.location" has way more information, but not standardized, what is the best way to incorporate all of these geo information?
Like I said in "1)" anything under user.* is user defined. So for example you can say you're from Mars, but if you have geo enabled and you tweet, tweet.coordinates will give the true location (most likely not Mars).
That percentage is low, but it's hard to say. It all depends on the location you're defining, if you're talking about the whole world tweet there's no specific number you can base that off of. From experience, I can tell you that (if no word filter is included) the US has roughly 10% geo information for tweets. The reason I say no word filter is because once you search tweets based off of words you're including biased data to your system.

Geocoding Accuracy

I'm brand new to geocoding and have a relatively large dataset of addresses 100,000+. When I geocode them using MapMarker Professional I get about 10% that I'm not able to geocode with a high level of precision (I get mostly S2 precision values back which mean that it was able to match to a Primary Postal Code centroid, centerpoint of the Primary Postal Code boundary). Each of the addresses has already been standardized so they should be valid (I have taken a random sample and run them through the USPS Zip Code Lookup process to verify this). My question is, should I be able to geocode addresses with a higher degree of accuracy than what I'm seeing or am I expecting too much of the products currently on the market? I've tried geocoding using google and yahoo's services without any better luck. All of the services appear to be able to give me the postal code centroid, but none of them appear to have enough information to be able to give me distinct coordinates for houses in at least 98% of the addresses I send to it.
Thanks for any guidance you can provide,
Jeremy
Geocoding is an imprecise process. The addresses you are geocoding that don't have good precision are likely in rural areas, where it is not uncommon for addresses to be off by up to a mile.
They only know where addresses are by taking the number at the start and end of a street segment, and dividing from there.

Get nearby hospitals or fire stations based on your location?

Is it possible to calculate nearby hospitals or police or fire stations based on your location using geocoding? For instance: If I'm from place Chennai, India. Using Geocoding I need to get the list of all hospitals or police or fire stations nearby Chennai.
If you have a list of the latitude and longitude of those hospitals and fire and police stations (as well as your own latitude and longitude), then sure it is possible. The calculation of the distance between two points on a sphere (like Earth) is called the Haversine formula. You'd have to iterate over each one, calculating how far you were from it. To speed things up, you might want to implement a geospatial index like the ones in MongoDB, SQL Server, Oracle, SOLR, etc.
You can get nearby hospitals, police or fire stations etc based on your location by only using Google Places API though this API is paid so you need to have a billing account to use this API.

Details of Bing Confidence Levels

Has anyone found a more complete description of what the Bing Confidence Enumeration values actually mean?
I'm trying to reconcile the results against another source of address data that has confidence values such as City, Street and Specific Address, and I want to get a feel for where the Bing results sit on this scale. I'm using the RESTful API.
The MSDN documentation only states that "High = The geocode service has high confidence in the match." etc.
Based on the MSDN documentation, you will be able to find various values for this property.
See: http://msdn.microsoft.com/en-us/library/ff701725.aspx
Extracted from the documentation:
The level of confidence that the geocoded location result is a match.
Use this value with the match code to determine for more complete
information about the match.
The confidence of a geocoded location is based on many factors
including the relative importance of the geocoded location and the
user’s location, if specified. The following description provides more
information about how confidence scores are assigned and how results
are ranked.
If the confidence is set to High, one or more strong matches were
found. Multiple High confidence matches are sorted in ranked order by
importance when applicable. For example, landmarks have importance but
addresses do not.
If a request includes a user location or a map area (see User Context
Parameters), then the ranking may change appropriately. For example, a
location query for "Paris" returns "Paris, France" and "Paris, TX"
both with High confidence. "Paris, France" is always ranked first due
to importance unless a user location indicates that the user is in or
very close to Paris, TX or the map view indicates that the user is
searching in that area.
In some situations, the returned match may not be at the same level as
the information provided in the request. For example, a request may
specify address information and the geocode service may only be able
to match a postal code. In this case, if the geocode service has a
high confidence that the postal code matches the data, the confidence
is set to High and the match code is set to UpHierarchy to specify
that it could not match all of the information and had to search
up-hierarchy.
If the location information in the query is ambiguous, and there is no
additional information to rank the locations (such as user location or
the relative importance of the location), the confidence is set to
Medium. For example, a location query for "148th Ave, Bellevue" may
return "148th Ave SE" and "148th Ave NE" both with Medium confidence.
If the location information in the query does not provide enough
information to geocode a specific location, a less precise location
value may be returned and the confidence is set to Medium. For
example, if an address is provided, but a match is not found for the
house number, the geocode result with a Roadblock entity type may be
returned. You can check the entityType field value to determine what
type of entity the geocode result represents. For a list of entity
types, see Entity Types.