How to transform geocode to real address in R - r

I used the twitteR package to extract data from Twitter API, and now I try to filter data by country name.
Most geocode packages are designed for inputting the real address and returning the corresponding geocode, but my needs are just the opposite.
For example, when I input c(38.897957, -77.036560), the result is "Whitehouse, D.C., U.S."

I ran into the revgeo package which performs Reverse Geocoding with the Photon Geocoder for OpenStreetMap,Google Maps, and Bing .
By default it uses photon which provides free data.
I'm using the example from the package itself.
require(revgeo)
revgeo(longitude=-77.0229529, latitude=38.89283435)
#"700 Pennsylvania Avenue Northwest, City Not Found, Washington, D.C., 20004, United States of America"
You can give it a try.
This blog below does mention that some locations are missing form their dataset, and it throttles down the speed after certain number of queries. There are other good pointers at the blog. https://towardsdatascience.com/reverse-geocoding-in-r-f7fe4b908355

Related

Reverse geocode latitude/longitude coordinates to retrieve landuse data (eg. residential area, highway, etc.)

I would like to analyse the locations of electric vehicle charging stations for Germany, Italy and France. Those three countries, because they differ quite a lot in regard to their respective incentive programmes for public charging station infrastructure.
What I have so far are .csv exports from both OpenChargeMap and OpenStreetMap containing the location data (latitude and longitude) of all charging stations in those three countries along with a few other information that I can process in R.
What I would like to do now is some sort of reverse geocoding on those latitude and longitude coordinates to retrieve additional information on the surroundings. Especially, whether the respective charging station is located in a residential area in a city for example or at a rest stop on the highway. By knowing at what kind of locations the charging stations are placed in those three countries I am hoping to be able to draw conclusions regarding the incentive programmes. I'm not looking for specific addresses in this case, but rather an API or another way to process thousands of coordinates and retrieve information regarding for example population density or any other piece of data from which I could derive conclusions.
I have tried to get OpenStreetMap exports to work, but unfortunately I cannot seem to be able to query for the 'landuse' attribute through the Overpass Turbo API. This is my basic query that I'm using in this specific API, but as soon as I query for ["landuse" = "residential"] instead of ["landuse" = ""] I get prompted empty fields as result.
I found an API from Google which would offer lookup for various address components/types. Unfortunately, registering an API key at Google is not quite realistic for the scope of my work. Does somebody know of a (preferably FOSS) API that is able to do something like this? Or even how to make a 'landuse' query work in the Overpass Turbo API linked above?
Thank you in advance for your time.
Your Overpass API query is looking for elements that are tagged as amenity=charging_station and landuse. This is rather uncommon since charging stations and landuse are mapped as distinct objects. Instead you need to look around charging stations for landuse elements.
So instead of
area["ISO3166-1"="DE"]->.a;
nwr(area.a)["amenity"="charging_station"]["landuse"=""];
you will need a query like
area["ISO3166-1"="DE"]->.a;
nwr(area.a)["amenity"="charging_station"];
way(around:200)["landuse"];
This searches for ways with a landuse tag located within 200 meters of charging stations.
Note that this is a rather heavy query. You should probably use your own Overpass API server for it.

Using Google Maps API to geocode NYC high schools by BN code

I am trying to geocode NYC high schools by using the Maps Geocoding API and the unique BN code assigned to each high school. For example, typing K733 into Google Maps results in a marker on MESA Charter High School in Brooklyn, NY. However, when I use the API url like so:
https://maps.googleapis.com/maps/api/geocode/json?address=K733
I keep getting "ZERO_RESULTS". I've also tried using the Places API and I've gotten the same results. Can anyone point me in the right direction? Is it even possible to pull this information from Google Maps?
It not possible to use unique BN codes for Maps Geocoding API because the address component requires postal address
address — The street address that you want to geocode, in the format
used by the national postal service of the country concerned.
Additional address elements such as business names and unit, suite or
floor numbers should be avoided. Please refer to the FAQ for
additional guidance.

Google Maps Api Airport Search

I am trying to get a list of nearby airports, given a certain location.
You can do this through the google places api and using types=airport.
The problem is that Google Places is self-policing so any tom, dick and harry can call themselves an airport.
Is there any way to determine whether an airport is real - through google maps?
I know I could double check against an airports database but then I'd be best just using an external database and only use google maps to plot their locations!!
thanks
Geonames will give you airports eg. a search centred on Central Park New York with a radius of 25 kms.
http://api.geonames.org/findNearby?lat=40.776902&lng=-73.968887&fcode=AIRP&radius=25&maxRows=100&username=xxxxx`.
You will need to open a (free) Geonames account to make it work.
Such a search would be in your "external database" category but as far as I know, the entries are not self-certified, so are possibly more reliable than Google's from what you say.
To verify Google results against Geonames results would need to develop and code your own comparison algorithm.

Google Maps API v3 street address vs city, zip

I am using Google Maps API v3 Distance. It has worked well for the majority of the addresses in my database. However, it seems like some addresses just aren't available in Google Maps, and it seems to pick the closest street address match which could be way off. I would expect Google Maps in this case to provide an answer based on city and zip. Does anyone have a solution? I've thought of double checking mathematically by geocode and checking Yahoo maps(or other sites) for the ones that are way off but that adds processing time and is not a very elegant solution. There must be some setting I'm missing or other such work around.
Thanks!
BTW shout out to the new Json Serializer! Well it was new to me anyways.
How are you formatting the address you are sending ?
I've used the Google Maps API to do some reverse geocoding and if a street could not be found (due to a typo or what have you) Google would return the lat lng for the historic town center.
I structured addresses as Country, city cityzip, street nr.
You should use the location_type of the geometry object to determine what accuracy was returned. I suggest checking to see if the returned resulsts indicate whether a result is anything other than ROOFTOP or RANGE_INTERPOLATED.

Where to get geography data?

I need geography data for new website.
Data required is
States (With names and standard abbreviations)
ZipCode (List of zip code with all available data like where zipcode belongs to)
What would be my best source to get this data?
Any help is appreciated.
Thanks for all answers,
Sorry i went offline for fewdays. Yes i am talking about US zipcode data.
I think postal service data most reliable I will go with that.
Other alternative mentioned has similar and in better format data. but i think going with postal service will be the best option
(US assumed, "zip code" sort of implies the US 5-digit code, whereas "postal code" is the generic term)
States and their abbreviations are easy, it's on the Postal Service website. (including Guam & other parts of the US that aren't states)
Zip codes: the Postal Service would be the authority in question, but it looks like they don't offer the basic database of zipcode <-> town, other than through an interactive one-by-one lookup. They do offer street-level zipcode databases and other information for $ale. However the Census Bureau has a nearly identical set of information available. (ZCTA = ZIP Code Tabulation Areas) This has also been prepackaged more easily in a Sourceforge project (in their forum they claim this is from the Census Bureau data).
For postal codes Maxmind Free Postalcode Database is the most comprehensive freely available list I know of.
For a list of countries with names and ISO ALPHA-3 codes see Countries or areas, codes and abbreviations.
Of course there is Wikipedia with a list and some pointers to other useful resources Wikipedia - List of Countries
Here's a torrent that might help: http://www.mininova.org/tor/761374
I believe it's legal since it's just geographic data that's publicly available. Also, if you're looking for an access database: http://databases.about.com/od/access/a/zipcodedatabase.htm
For what country? Australia Post has a downloadable file with all the data you're after here. Seems like the sort of thing postal services in other countries would also provide.
Edit: was just listening to .NET Rocks no. 437 and Bob Beauchemin mentions most of this data is available at census.gov
I assume you're talking about the US (if you need states and zip codes...).
The TIGER/Line data is freely available. Not sure if it includes zip codes etc, but worth a look, since it's in the public domain.
Or you can check data.geocomm.com. I don't know what the exact legal status of that is though.

Resources