Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import my_overpass api = my_overpass.API() qs = my_overpass.MapQuery(38.799, -77.041, 38.801, -77.039) features = api.Get(qs) for feat in features: print(feat) the guidelines the sample output: In

import my_overpass api = my_overpass.API() qs = my_overpass.MapQuery(38.799, -77.041, 38.801, -77.039) features = api.Get(qs) for feat in features: print(feat)

image text in transcribedimage text in transcribed

the guidelines

image text in transcribedimage text in transcribed

the sample output:

In the specified bounding box surrounding (38.8,-77.04): + There are 1 water sources:

 river + There are 45 buildings, named buildings include: 
 Robinson Terminal + There are 2 places of leisure, named areas include: 
 Windmill Hill Park Shipyard Park 

In the specified bounding box surrounding (39.167,-78.156): + There are no water sources: + There are 6 buildings, named buildings include:

 Campus Maintenance Wilkins Administration Bldg Goodson Chapel & Recital Hall Aikens Athletic Center Maintenance Shop Shingleton Hall 
 + There are 4 places of leisure, named areas include: Harry W Aikens Field Aikens Athletic Center 

Programming language: Python, need help coding this question, especially the three functions and the user input.

OSM Parsing. This assignment will query OpenStreetMap (OSM) using a lightweight python wrapper named Overpass: github link. Prerequisites: In order to painlessly install this module you will need to use pip package manager (Follow the directions in the course material page for installing). Then in the command-line you can just type 'pip install overpass You can verify the install by running python, and in script mode >>> import overpass If no error! then it is installed! Yay! OSM Learning Goals 1. Use a PyPl module - successfully load and execute a query on OSM 2. Create at least 3 custom functions getWaterFeatures(feats) getBuilding Features(feats) getPlacesOfLeiesure(feats) 3. For each of the above functions: Iterate through features to count the features of each type: ['Water','Building','Leisure'l and extract any feature that is named... Should return a number and a list of names. Takes as parameter the list of features from a bounding box. 4. Put together a program that asks the user for a latitude and longitude (how to input is up to you so long as the Ul is clear) 5. Call overpass functions and your functions to provide appropriate output, and format it to match the examples at the end... 6. When calling MapQuery use a small bounding box as shown on the next slide (2 thousandths of a degree) Below is an example of using overpass: A >>> import overpass >>> api = overpass.API() > qs = overpass.MapQuery (38.799, -77.041, 38.801, -77.039) >>> response = api.Get (as) >>> feats = response [' features'] >>> print (type (feats)) >>> print (feats [220]) {"geometry": {"coordinates": [[-77.0411138, 38.7997731], [-77.0411024, 38.7998339], [-77.0409213, 38.7998124], [-77.0409342, 38.7997504], [-77.0411138, 38.7997731]], " type": "LineString"}, "id": 190533700, "properties": { "addr :housenumber": "464", "addr:postcode":"22314", "addr: street": "South Union Street", "building": "house", " building:levels": "3", "source": "Bing; survey" }, "type": " Feature" } NOTE: Each feature is a dictionary...the "interesting" key here is the properties key...which is another dictionary (it may contain what you are interested in) Below is a starting point for your python code: import overpass # getWaterFeatures (...) must be defined here... # Signature, and definition is omitted # This function must return the count and list of water type features... # Ditto for get BuildingFeatures (...) # Ditto for getLeisureFeatures (...) # printFeats (lat, lon) may be defined here (NOT REQUIRED)... inside this function would create a bounding box around the lat/lon... and get the features list # Assuming it is, below is an example execution for two lat/lon combos...use the following output for cross reference printFeats (38.8, -77.04) # Alexandria print('') print Feats (39.167, -78.156) # Winchester Output format on next slides of given Alexandria and Winchester latitude and longitudes... OSM Parsing. This assignment will query OpenStreetMap (OSM) using a lightweight python wrapper named Overpass: github link. Prerequisites: In order to painlessly install this module you will need to use pip package manager (Follow the directions in the course material page for installing). Then in the command-line you can just type 'pip install overpass You can verify the install by running python, and in script mode >>> import overpass If no error! then it is installed! Yay! OSM Learning Goals 1. Use a PyPl module - successfully load and execute a query on OSM 2. Create at least 3 custom functions getWaterFeatures(feats) getBuilding Features(feats) getPlacesOfLeiesure(feats) 3. For each of the above functions: Iterate through features to count the features of each type: ['Water','Building','Leisure'l and extract any feature that is named... Should return a number and a list of names. Takes as parameter the list of features from a bounding box. 4. Put together a program that asks the user for a latitude and longitude (how to input is up to you so long as the Ul is clear) 5. Call overpass functions and your functions to provide appropriate output, and format it to match the examples at the end... 6. When calling MapQuery use a small bounding box as shown on the next slide (2 thousandths of a degree) Below is an example of using overpass: A >>> import overpass >>> api = overpass.API() > qs = overpass.MapQuery (38.799, -77.041, 38.801, -77.039) >>> response = api.Get (as) >>> feats = response [' features'] >>> print (type (feats)) >>> print (feats [220]) {"geometry": {"coordinates": [[-77.0411138, 38.7997731], [-77.0411024, 38.7998339], [-77.0409213, 38.7998124], [-77.0409342, 38.7997504], [-77.0411138, 38.7997731]], " type": "LineString"}, "id": 190533700, "properties": { "addr :housenumber": "464", "addr:postcode":"22314", "addr: street": "South Union Street", "building": "house", " building:levels": "3", "source": "Bing; survey" }, "type": " Feature" } NOTE: Each feature is a dictionary...the "interesting" key here is the properties key...which is another dictionary (it may contain what you are interested in) Below is a starting point for your python code: import overpass # getWaterFeatures (...) must be defined here... # Signature, and definition is omitted # This function must return the count and list of water type features... # Ditto for get BuildingFeatures (...) # Ditto for getLeisureFeatures (...) # printFeats (lat, lon) may be defined here (NOT REQUIRED)... inside this function would create a bounding box around the lat/lon... and get the features list # Assuming it is, below is an example execution for two lat/lon combos...use the following output for cross reference printFeats (38.8, -77.04) # Alexandria print('') print Feats (39.167, -78.156) # Winchester Output format on next slides of given Alexandria and Winchester latitude and longitudes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

Differentiate between intelligence testing and achievement testing.

Answered: 1 week ago

Question

What should Sheila have done to avoid interviews like this one?

Answered: 1 week ago