Obtain road type from nominatim - geocoding

Is there a way of obtaining the type of road an object is settled in from a request via nominatim?
For example
http://nominatim.openstreetmap.org/reverse?format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1
does provide me with loads of info. yet, there is no info on the road the address is settled in. would like to obtain something like: rural road or even just grade*N* (where N stands for the level of hierarchy.) i hope what i'm looking for is understandable :) thanks in advance!

Nominatim is for searching addresses, you probably want to use the OverpassAPI to query roads around the given coordinates:
http://overpass.osm.rambler.ru/cgi/interpreter?data=[out:json];way[highway](52.52,-1.82,52.55,-1.81);out;
Then choose the one matching your coordinates the best and look at the highway= value.

You can use format=jsonv2 instead of format=xml or format=json.
format=jsonv2 adds the next fields to response: place_rank,category, type,importance, addresstype.
I added this information to Nominatim Reverse Geocoding documentation.
When category tag contains value highway the type tag shows the road type.
Find more information about highway types at OpenStreetMap highway tag

Related

How to count number of citations/references in wikipedia raw text?

I'm building a model to classify raw Wikipedia text by article quality (Wikipedia has a dataset of ~30,000 hand-graded articles and their corresponding quality grades.). Nonetheless, I am trying to figure out a way to algorithmically count the number of citations that appear on the page.
As a quick example: here is an excerpt from a raw Wiki page:
'[[Image:GD-FR-Paris-Louvre-Sculptures034.JPG|320px|thumb|Tomb of Philippe Pot, governor of [[Burgundy (region)|Burgundy]] under [[Louis XI]]|alt=A large sculpture of six life-sized black-cloaked men, their faces obscured by their hoods, carrying a slab upon which lies the supine effigy of a knight, with hands folded together in prayer. His head rests on a pillow, and his feet on a small reclining lion.]]\n[[File:Sejong tomb 1.jpg|thumb|320px|Korean tomb mound of King [[Sejong the Great]], d. 1450]]\n[[Image:Istanbul - Süleymaniye camii - Türbe di Roxellana - Foto G. Dall\'Orto 28-5-2006.jpg|thumb|320px|[[Türbe]] of [[Roxelana]] (d. 1558), [[Süleymaniye Mosque]], [[Istanbul]]]]\n\'\'\'Funerary art\'\'\' is any work of [[art]] forming, or placed in, a repository for the remains of the [[death|dead]]. [[Tomb]] is a general term for the repository, while [[grave goods]] are objects—other than the primary human remains—which have been placed inside.<ref>Hammond, 58–9 characterizes [[Dismemberment|disarticulated]] human skeletal remains packed in body bags and incorporated into [[Formative stage|Pre-Classic]] [[Mesoamerica]]n [[mass burial]]s (along with a set of primary remains) at Cuello, [[Belize]] as "human grave goods".</ref>
So far, I've concluded that I can find the number of images by counting the number of [[Image: occurrences. I was hoping I could do something similar for references. In fact, after comparing raw Wiki pages and their corresponding live pages, I think I was able to determine that </ref> corresponds to the end notation of a reference on a Wiki page. --> For example: Here, you can see that the author makes a statement at the end of the paragraph and references Hammond, 58–9 within <ref> {text} </ref>
If somebody is familiar with Wiki's raw data and can shed some light on this, please let me know! Also, if you know a better way to do this, please tell me that, too!
Many thanks in advance!
ref not always contains link to source. Sometimes contain specify explanations and etc.
You must counting not only <ref>...</ref>, but also footnote templates.
If you need count of unique refs, then you must except grouped refs (ref with name="xxx" parameter or auto grouped footnotes templates with same content).
Sorry for my English.
Counting reference tags in wiki markup isn't necessarily accurate as references can be reused so that two </ref> would only show up as one reference in the list at the end. There is an API that should give a list of the articles, but for some reason it's deactivated, but BeautifulSoup makes this pretty simple. I haven't tested this to check it counts all articles correctly, but it works:
from bs4 import BeautifulSoup
import requests
page=requests.get('https://en.wikipedia.org/wiki/Stack_Overflow')
soup=BeautifulSoup(page.content,'html.parser')
count = 0
for eachref in soup.find_all('span', attrs={'class':'reference-text'}):
count = count + 1
print (count)

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

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! :)

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... :)

House number parameter in cloudmade doesn't work

I've problem with the house Parameter of the cloudmade geocoding API.
i.e. I'am looking for house number 10 in the German City Gießen:
http://geocoding.cloudmade.com/8ee2a50541944fb9bcedded5165f09d9/geocoding/v2/find.html?query=zipcode:35390;city:giessen;house:10;street:bahnhofstrasse;country:Germany&return_geometry=true&results=1
cloudmade finds the correct street, but number 10 is not in the middle of the street. I've the same problem with all streets.
The API documentation sais I am right: http://developers.cloudmade.com/projects/show/geocoding-http-api#Structured-search
They seem to ignore the house key and just return the same result as if it hasn't been provided. But searching on http://maps.cloudmade.com/ returns the same vague result. While the data you are searching for is in OSM's data base it might not be in CloudMade's data base for whatever reason. Therefore I guess this is a problem with CloudMade's geocoding database and not a problem of their API.
Sometimes there are no house number data in our data set, so we return only street. Also in couple of months we'll launch new geocoding with more detailed data.

How can I Implement Yelp's Map Search and Search by zip code or by city name

How can I implement yelp like search?
There are 2 types of searches on yelp.
Simple search using the zip code, city and state in U.S.
I'm using PostgreSQL and wonder if there is good dataset that I can use that has city, state and zip code. I was hoping to find a good geo shape file and use geoDjango where I can just use, say Store.objects.filter(coordinates__in=cityNameORZipCode).
There seem to be some zip code database that I can use, but I really don't know where I can find a good city, state. The last option is to create my own cityname and state table and link to Stores, but not sure if this is smart thing to do.....hm.
Yelp has map search.
If you zoom in or out the google map, it searches local businesses according to the map area you are viewing. Think this is amazing. How can I do this?
It's looking dark right now. Please shed me some light.
You're asking a very broad and unanswerable question, but a good place to start for data in the U.S. is at the Census Bureau. For example:
State and State Equivalent Areas
County and County Equivalent Areas
The full list:
http://www.census.gov/geo/www/cob/bdy_files.html