Write a Python script that downloads data from a web service. This can be any GIS web service and the data extracted can be points or rasters (we have not yet covered how to work with polylines and polygons in web services). You'll need to download at least 4 data elements (points or rasters) and save them to a file so they can be loaded into a GIS application.
Sorry, this lab was not very clear. There are two ways to complete this lab:
1. You can download data from links on a web page. The web page approach could be http or ftp based. The "data elements" can be four files that can be loaded into a GIS package (e.g. shape files, georeferenced TIFFs). You don't need to unzip this file through Python. You just need to download the file and then you can manually unzip it.
2. The alternative is to download data from a "web service" such as coordinates from the Google Geocoding API. You'll need to download at least four features and save them to one or more files. Then, you can parse the file with the assignment below.
Write a script that extracts the spatial data, with at least one attribute, from an XML file. The file can be from a web service or another source. Then, write the parsed data into a CSV file that can be loaded into a GIS application. The script should be able to extract all the data from a file (i.e. put it in a while loop).
Place your code into a function where you pass in the input (original XML file) file path and the output (CSV file) file path to save the file to. Then, place this in a separate file named "URLUtil.py" that you import into your main script.
Turn in three Python code files:
Add the scripts to a Zip file with any other data that is needed to run the scripts. Have your scripts use the "C:/Temp" folder for the files that are downloaded by your scripts and the files your scripts write out.
Make sure you've placed try/except blocks around each of your main sections of code.
© Copyright 2018 HSU - All rights reserved.