Geolocation, Is it possible to get latitude and longitude from address and store locally in my database - geolocation

I want to be able to run queries locally comparing latitude and longitude of locations so I can run queries for certain addresses I've captured based on distance.
I found a free database that has this information for zip codes but I want this information for more specific addresses. I've looked at google's geolocation service and it appears it's against the TOS to store these values in my database or to use them for anything other than doing stuff with google maps. (If somebody's looked deeper into this and I'm incorrect let me know)
Am I likely to find any (free or pay) service that will let me store these lat/lon values locally? The number of addresses I need is currently pretty small but if my site becomes popular it could expand quite a bit over time to a large number. I just need to get the coordinates of each address entered once though.

This question hasn't received enough attention...
You're correct -- it can't be done with Google's service and still conform to the TOS. Cheers to you for honestly seeking to comply with the TOS.
I work at a company called SmartyStreets where we process addresses and verify addresses -- and geocode them, too. Google's terms don't allow you to store the data returned from the API, and there's pretty strict usage limits before they throttle or cut off your access.
Screen scraping presents many challenges and problems which are both technical and ethical, and I don't suppose I'll get into them here. The Microsoft library linked to by Giorgio is for .NET only.
If you're still serious about doing this, we have a service called LiveAddress which is accessible from any platform or language. It's a RESTful API which can be called using GET or POST for example, and the output is JSON which is easy to parse in pretty much every common language/platform.
Our terms allow you to store the data you collect as long as you don't re-manufacture our product or build your own database in an attempt to duplicate ours (or something of the like). For what you've described, though, it shouldn't be a problem.
Let me know if you have further questions about address geocoding; I'll be happy to help.
By the way, there's some sample code at our GitHub repo: https://github.com/smartystreets/LiveAddressSamples

http://www.zip-info.com/cgi-local/zipsrch.exe?ll=ll&zip=13206&Go=Go could use a screen scraper if you just need to get them once.

Also Microsoft provides this service. Check if this can help you http://msdn.microsoft.com/en-us/library/cc966913.aspx

Related

Are there any free GeoIP services which are accurate to detect whether 2 addresses are within 6Km?

I have to make a restaurant home delivery website, and the owners do not wish to deliver more than 6km away. I hear that the geoIP DB 'Maxmind GeoLite city' is not particularly accurate though. Furthermore if you know of a database that has a shortcode, or predefined query for obtaining the distance without loads of coding, I would love to hear about it! I hope the question is well defined enough. All advice welcome!
I don't know the specification of your project, but it's likely you do know the delivery address. In this case you could use Google's Geocoding APIs to get the position (lat,lng) and then calculate the distance.
Of course there are limitations in the amount of daily requests, but I hardly think your app will reach that limit.
Take a look here:
https://developers.google.com/maps/documentation/geocoding
As far as I know, there are no free IP geolocation databases that will reliably provide the accuracy you are looking for, especially if your client has visitors using mobile devices.
I would recommend that you take a look at W3C Geolocation JavaScript API. The results from this will often be more accurate than IP geolocation, especially if the user is on a device with GPS. Do note that it will pop up a dialog asking the user whether they want to share their location with your site.
HTML5 geo location if far more accurate than IP address based location.
http://ipgeo5.com/

Offline reverse geocoding on iOS

There are lots of existing questions relating to this issue, but I have looked at as many of them as I could find and did not get an answer.
I'm trying to perform an offline reverse geocoding lookup on iOS based on a latitude and longitude. I'd like to be able to provide a latitude and longitude, and be provided with the country in which that point lies. I can do this with Geonames (such as: http://api.geonames.org/countryCode?lat=45.03&lng=8.2&username=demo), but I need a similar ability offline, without Internet functionality on the device.
CLLocation does not provide offline services that work reliably enough for what I'm doing, it relies on caches made while you were previously online, etc. Messy.
I've tried this: https://github.com/drodriguez/reversegeocoding but haven't had any luck, it requires some slightly complex / confusing Terminal installations using something called Thor which I've never heard of, and was throwing up a variety of errors, so I bailed on it.
I've found a few downloadable maps, but these seem to be even more complicated, and worryingly, hundreds of megabytes or even gigabytes in size – much beyond the scope of an iOS app. I only need countries, nothing smaller than that (cities, streets, locations, etc.) so I think I should be able to get a much smaller file.
So my key question is: is there some pre-existing database or tool, preferably with iOS support, that I can feed a latitude/longitude, and get a country? And, if not, what steps should I take to get such functionality working on my own?
Thanks in advance.
ReverseGeocodeCountry is a simple lightweight offline country reverse geocoder for iOS, it has a static JSON file with country polygon data that is used to reverse geocode any lat/lng:
https://github.com/krisrak/ios-offline-reverse-geocode-country
The "Countries of the World" is a .csv text file with countries, coordinates, localised country names, capitals and other information. It seems to be free to use. You just have to import it into an SQLite database.
Edit Just noticed you want reverse geocoding. The database would only be good for forward geocoding.
You can download shapefiles for all countries at http://www.gadm.org/download. If you download a .kmz, you can unpack it to a list of coordinates for the borders. You could probably take every 5th or 10th coordinate to get smaller size (with less accuracy).
Just in case I can suggest another good written offline geocoding library.
https://github.com/Alterplay/APOfflineReverseGeocoding

Reverse geocoding services

I'm working on a project that returns information based on the user's location. I also want to display the user's town in text (no map) so they can change it if it's not accurate.
If things go well I hope this will be more than a small experiment, so can anyone recommend a good reverse geocoding service with the least restrictions? I notice that Google/Yahoo have a limit to the number of daily queries along with other usage terms. I basically need to take latitude and longitude and convert them to a city/town (which I presume cannot be done using the HTML5 Geolocation API).
Geocoda just launched a geocoding and spatial database service and offers up to 1K queries a month free, with paid plans starting at $49 for 25,000 queries/month. SimpleGeo just closed their Context API so you may want to look at Geocoda or other alternatives.
You're correct, the browser geolocation API only provides coordinates.
I use SimpleGeo a lot and recommend them. They offer 10K queries a day free then 0.25USD per 1K calls after that. Their Context API is what you're going to want, it pretty much does what is says on the tin. Works server-side and client-side (without requiring you to draw a map, like Google.)
GeoNames can also do this and allows up to 30K "credits" a day, different queries expend different credit amounts. The free service has highly variable performance, the paid service is more consistent. I've used them in the past, but don't much anymore because of the difficulty of automatically dealing with their data, which is more "pure" but less meaningful to most people.

How do I find a place of business from geolocation information?

Let's say I'm just wondering around with my cellphone and I want to know exactly which place of business I'm in. This would seem to be easy, but I don't see away to do it. It's possible to reverse geocode but this gives an address range. Google doesn't seem to have http base local search using local information, because you could kind of guess from the local search or points of interest. It needs to be through an http API, not an ajax driven map. Is there a way to do this?
You might look at GeoAPI, which lets you search for businesses near a particular lat/lon coordinate and returns detailed information about the business (name, type, hours, etc.). It's a simple JSON API with good documentation and examples.
There's likely more APIs out there for local business data -- which I personally would love to hear about if people want to add them as answers to this question or comments on my answer. What's your favorite? What are the advantages and disadvantages?

Finding City and Zip Code for a Location

Given a latitude and longitude, what is the easiest way to find the name of the city and the US zip code of that location.
(This is similar to https://stackoverflow.com/questions/23572/latitude-longitude-database, except I want to convert in the opposite direction.)
Related question: Get street address at lat/long pair
Any of the online services mentioned and their competitors offer "reverse geocoding" which does what you ask--convert lon/lat coordinates into a street address of some-sort.
If you only need the zip codes and/or cities, then I would obtain the Zip Code database and urban area database from the US Census Bureau which is FREE (paid for by your tax dollars). http://www.census.gov/geo/www/cob/zt_metadata.html.
From there, you can either come up with your own search algorithm for the spatial data or make use of one of a spatial databases such as Microsoft SQL Server, PostGIS, Oracle Spatial, ArcSDE, etc.
Update: The 2010 Census data can be found at:
http://www2.census.gov/census_2010/
This is the web service to call.
http://developer.yahoo.com/search/local/V2/localSearch.html
This site has ok web services, but not exactly what you're asking for here.
http://www.usps.com/webtools/
You have two main options:
Use a Reverse Geocoding Service
Google's can only be used in conjunction with an embedded Google Map on the same page, so I don't recommend it unless that is what you are doing.
Yahoo has a good one, see http://developer.yahoo.com/search/local/V3/localSearch.html
I've not used OpenStreetMap's. Their maps look very detailed and thorough, and are always getting better, but I'd be worried about latency and reliability, and whether their address data is complete (address data is not directly visible on a map, and OpenStreetMap is primarily an interactive map).
Use a Map of the ZIP Codes
The US Census publishes a map of US ZIP codes here. They build this from their smallest statistical unit, a Census Block, which corresponds to a city block in most cases. For each block, they find what ZIP code is most common on that block (most blocks have only one ZIP code, but blocks near the border between ZIP codes might have more than one). They then aggregate all the blocks with a given ZIP code into a single area called a Zip Code Tabulation Area. They publish a map of those areas in ESRI shapefile format.
I know about this because I wrote a Java Library and web service that (among other things) uses this map to return the ZIP code for a given latitude and longitude. It is a commercial product, so it won't be for everyone, but it is fast, easy to use, and solves this specific problem without an API. You can read about this product here:
http://askgeo.com/database/UsZcta2010
And about all of your geographic offerings here:
http://askgeo.com
Unlike reverse geocoding solutions, which are only available as Web APIs because running your own service would be extremely difficult, you can run this library on your own server and not depend on an external resource.
If you call volume to the service gets up too high, you should definitely consider getting your own set of postal data. In most cases, that will provide all of the information that you need, and there are plenty of db tools for indexing location data (i.e. PostGIS for PostgreSQL).
You can buy a fairly inexpensive subscription to zipcodes with lat and long info here: http://www.zipcodedownload.com/
Or google's reverse geocoding
link
http://maps.google.com/maps/geo?output=xml&q={0},{1}&key={2}&sensor=true&oe=utf8
where 0 is latitude 1 is longitude
geonames has an extensive set of ws that can handle this (among others):
http://www.geonames.org/export/web-services.html#findNearbyPostalCodes
http://www.geonames.org/export/web-services.html#findNearbyPlaceName
Another reverse geocoding provider that hasn't been listed here yet is OpenStreetMap: you can use their Nominatim search service.
OSM has the (potentially?) added bonus of being entirely user editable (wiki-like) and thus having a very liberal licencing scheme of all this data. Think of this of open source map data.

Resources