Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help doing this python assignment because it is kind of complex and I need to finish it as soon as possible. OSM Parsing.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

I need help doing this python assignment because it is kind of complex and I need to finish it as soon as possible.

OSM Parsing. 1 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 getWater Features(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'] 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) OSM Getting Started... Below is an example of using overpass: V V V V V V >>> 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) OSM Starting Code (guidelines) 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 get LeisureFeatures (...) # 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 print Feats (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 Starting Code (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 OSM Parsing. 1 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 getWater Features(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'] 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) OSM Getting Started... Below is an example of using overpass: V V V V V V >>> 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) OSM Starting Code (guidelines) 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 get LeisureFeatures (...) # 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 print Feats (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 Starting Code (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

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions