I need to extract street name and corresponding area name data from OSM using overpass-turbo - openstreetmap

I'm using overpass-turbo to extract street names data from OSM. Here's the code I've been using:
[out:csv ("name")][timeout:2500];
{{geocodeArea:Ouagadougou}}->.searchArea;
(
way["highway"]["name"](area.searchArea);
);
for (t["name"])
{
make street name=_.val;
out;
}
How should I modify the code so the output is street names with the corresponding area name?
[out:csv ("name")][timeout:2500];
{{geocodeArea:Ouagadougou}}->.searchArea;
(
way["highway"]["name"](area.searchArea);
);
for (t["name"])
{
make street name=_.val;
out;
}
Output is street names only.

Related

Overpass-turbo: add city name to a specific node

I'm requesting some drinking_water nodes by id:
node(id:1560728638,
1560728638,
1835271176,
1844271135
); out body;
I'd like to request the name of the city where the nodes are, for example:
osm_id
city
1560728638
city A
1560728638
city A
1835271176
city B
1844271135
city C
Is it possible?
In your case, the nodes already have a city tag: "addr:city"
You can ask and search question about overpass, OSM and various geographic queries on gis.stackexchange.com, it might be more focused that here.
Anyway, you can run the following query on overpass turbo:
// output to .csv file, with columns
[out:csv(::type,::id,amenity, name, "addr:city")];
// list of nodes
node(id:1560728638,
1560728638,
1835271176,
1844271135
);
//for each node:
// print the node,
// then get the surrounding (is_in),
// filter that for cities (admin_level 8),
// and return they city
foreach->.d(
.d out;
.d is_in;
area._[admin_level~"[8]"];
out;
);
So you get a list of your original nodes (in a different order), and the city they're in.
They you can just extract the data from the file o put in in the format you want:
#type
#id
amenity
name
addr:city
node
1835271176
drinking_water
Privas
area
3600087515
Privas
node
1560728638
drinking_water
Privas
area
3600087515
Privas
node
1844271135
drinking_water
Saint-Etienne-de-Serre
area
3602084772
Saint-Étienne-de-Serre

Fake email generation using factory.LazyAttribute

I am trying to generate fake email ID's for the purpose of research. I employ LazyAttribute towards this end. I want the email ID to correspond to the first and the last names of the person (generated using Faker). The function I wrote is below.
I am unable to get the expected output. If the name of the person is John Snow, I see the following as the output:
John Snow <factory.declarations.LazyAttribute object at ......
Can I expect some help to fix my code? Thanks!
def faker_categorical(num=1, seed=None):
np.random.seed(seed)
fake.seed_instance(seed)
output = []
for x in range(num):
gender = np.random.choice(["M", "F"], p=[0.5, 0.5])
output.append(
{
"First name": fake.first_name(),
"Last name": fake.last_name(),
"E-mail": factory.LazyAttribute(lambda obj: "%s#example.com" % obj.first_name),
})
return output

Get the list of cities, suburbs with relations from Overpass-turbo

I'm struggling to build a mini database set for with the following structure
{countryId, governorateId, cityId}
The idea is:
I need to find all admin_level=4 for Egypt, then for each result, get the cities|suburb|town
Example:
Cairo: ['Nasr City', 'Fifth Sattelment',...etc.]
Where Cairo = Governorate, 'Nasr City' = Suburb
What i have so far:
[out:csv(::id, 'place', 'name:ar', 'name:en')][timeout:25];
// fetch area “Egypt” to search in
{{geocodeArea:Egypt}}->.searchArea;
// gather results
(
node[place~"city|town|suburb"](area.searchArea);
);
// print results
out body;
>;
out skel qt;
which gives me the list, but without relations, so i have no clue which suburb is inside which city
When you write that query without filtering the columns it should return it will return a node like such:
<node id="21320911" lat="-33.9783333" lon="25.5874001">
<tag k="is_in" v="Port Elizabeth,Eastern Cape, South Africa"/>
<tag k="name" v="Walmer"/>
<tag k="place" v="suburb"/>
<tag k="sagns_id" v="62090"/>
<tag k="source" v="sagns"/>
<tag k="wikidata" v="Q61356595"/>
</node>
So, to extract the relations you can add the "is_in" column to the query so that it can look something like so...
[out:csv(::id, 'name', 'is_in', 'place')][timeout:25];
// fetch area “South Africa” to search in
{{geocodeArea:South Africa}}->.searchArea;
// gather results
(
node[place~"city|town|suburb|street"](area.searchArea);
);
// print results
out body;
>;
out skel qt;
and that should show your suburb and the city including the country. Eg:
#id name is_in place
21320910 Newton Park "Port Elizabeth, Eastern Cape, South Africa" suburb
21320911 Walmer "Eastern Cape, South Africa" suburb
21320912 Mill Park "Eastern Cape, South Africa" suburb
On my result set, it sometimes returns the city and sometimes doesn't...Hopefully this helps out.

Force query to match more than one attribute

I have an index that includes these attributes: Name, Address, City, State, Zip
I want to do a allOptional search but I don't want city, state, or zip to match without name or address also matching. So a search query of McDonalds would match all McDonalds in every city/state, McDonalds Chicago would return all McDonalds in Chicago and McDonalds 60007 would return all McDonalds in the zip code 60007.
But a search query of Chicago or Chicago IL would return 0 results.
I've been reading the filters and facets documentation and I think this should be possible with a filter but I can't seem to figure out how.
You can solve this issue by post processing results after you have received them, before rendering them.
You can use the _highlightResult data in the hits response to filter out hits in which the query isn't matched in certain attributes.
For instance to remove hits where the query isn't matched in either the name or address attribute:
var displayedResults = response.hits.filter(hit => {
return hit._highlightResult.name.matchLevel !== 'none' || hit._highlightResult.address.matchLevel !== 'none';
});

how to insert checkbox value to database in python

In the front end they are selecting multiple checkboxes i.e;(district,taluk)
,so how can i get the values to the backend and how to save in the database.
note: I want to write this code based on definition not generics
this is my models
class Example(models.Model):
district = models.CharField(max_length=20)
taluk = models.CharField(max_length=20)
if we give input in json format like
{
"Bangalore" :{
"dodballapura",
" Hosakote"
}
}
then it should save in database and
in the above example bangalore is the district and remaining are talukas