Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
29 views6 pages

Geoplotlib & Python Data Visualization

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views6 pages

Geoplotlib & Python Data Visualization

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Important Questions Module 4 & 5

1. Give the Conceptual architecture of geoplotlib.

Explain in details.
2. What is geoplotlib? Discuss the design principles of geoplotlib.
geoplotlib is an open-source Python library for geospatial data visualizations. It has a wide
range of geographical visualizations and supports hardware acceleration. It also provides
performance rendering for large datasets with millions of data points. As discussed in earlier
chapters, Matplotlib provides various ways to visualize geographical data.
Design principles of geoplotlib
Integration
import pandas as pd
from geoplotlib.utils import DataAccessObject
# data wrangling with pandas DataFrames here
dataset_obj = DataAccessObject(dataset_filtered)
Simplicity
# plotting our dataset as a dot density plot
import geoplotlib
from geoplotlib.utils import DataAccessObject
dataset_obj = DataAccessObject(dataset_filtered)
geoplotlib.dot(dataset_obj, f_tooltip=lambda d:d['City'].title())
geoplotlib.show()
Performance
geoplotlib can handle large amounts of data due to the use of NumPy for accelerated numerical
operations and OpenGL for accelerated graphical rendering.
3. Illustrate different tile providers using geoplotlib.
import geoplotlib
geoplotlib.show()
# using map tiles from the dark matter tile provider
geoplotlib.tiles_provider('darkmatter')
geoplotlib.show()
geoplotlib.tiles_provider({
'url': lambda zoom, xtile, ytile: 'http://a.tile.openstreetmap.fr/ hot/%d/%d/%d.png' % (zoom,
xtile, ytile),
'tiles_dir': 'custom_tiles',
'attribution': 'Custom Tiles Provider – Humanitarian map style'
})
geoplotlib.show()
4. Demonstrate the following Geospatial Visualizations.
i.Voronoi Tessellation
# plotting our dataset as voronoi plot
geoplotlib.voronoi(dataset_filtered, line_color='b')
geoplotlib.set_smoothing(True)
geoplotlib.show()
ii. Delaunay triangulation
# plotting our dataset as a delaunay
geoplotlib.delaunay(dataset_filtered, cmap='hot_r')
geoplotlib.set_smoothing(True)
geoplotlib.show()
5. Discuss the features and concepts of Bokeh.
Features of Bokeh
Simple visualizations
Excellent animated visualizations
Inter-visualization interactivity
Supports multiple languages
Multiple sways to perform a task
Beautiful chart styling
Features Explain in details
Concepts of Bokeh
6. Demonstrate the following widgets using python.
i)Checkbox ii) Text iii) Dropdown
# importing the widgets
from ipywidgets import interact, interact_manual
# creating an input text
@interact(Value='Input Text')
def text_input(Value):
print(Value)
@interact(Value=False)
def checkbox(Value=False):
print(Value)
# creating a dropdown
options=['Option1', 'Option2', 'Option3', 'Option4']
@interact(Value=options)
def dropdown(Value=options[0]):
print(Value)
7.What is a protocol? Develop a python program to make connection to the server using
HTTP.
A protocol is a set of precise rules that determine who is to go first, what they are to do, and
then what the responses are to that message, and who sends next.
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('data.pr4e.org', 80))
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\r\n\r\n'.encode()
mysock.send(cmd)
while True:
data = mysock.recv(512)
if len(data) < 1:
break
print(data.decode(),end='')
mysock.close()
8.Illustrate the following:
i. Retrieving web pages with urllib
import urllib.request
fhand = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')
for line in fhand:
print(line.decode().strip())
ii. Reading binary files using urllib
import urllib.request, urllib.parse, urllib.error
fhand = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')
counts = dict()
for line in fhand:
words = line.decode().split()
for word in words:
counts[word] = counts.get(word, 0) + 1
print(counts)
9.Show the SOA architecture of Application Programming Interfaces and
explain about it.

Explain in details.
10.Demonstrate the way of parsing a JSON file.
import json
data = '''
[
{ "id" : "001",
"x" : "2",
"name" : "Chuck"
},
{ "id" : "009",
"x" : "7",
"name" : "Brent"
}
]'''
info = json.loads(data)
print('User count:', len(info))
for item in info:
print('Name', item['name'])
print('Id', item['id'])
print('Attribute', item['x'])
11.Demonstrate the process of retrieving an image using HTTP.
import socket
import time
HOST = 'data.pr4e.org'
PORT = 80
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect((HOST, PORT))
mysock.sendall(b'GET http://data.pr4e.org/cover3.jpg HTTP/1.0\r\n\r\n')
count = 0
picture = b""
while True:
data = mysock.recv(5120)
if len(data) < 1: break
#time.sleep(0.25)
count = count + len(data)
print(len(data), count)
picture = picture + data
mysock.close()
# Look for the end of the header (2 CRLF)
pos = picture.find(b"\r\n\r\n")
print('Header length', pos)
print(picture[:pos].decode())
# Skip past the header and save the picture data
picture = picture[pos+4:]
fhand = open("stuff.jpg", "wb")
fhand.write(picture)
fhand.close()
12. Illustrate the following:

i. Parsing XML
import xml.etree.ElementTree as ET
data = '''
<person>
<name>Chuck</name>
<phone type="intl">
+1 734 303 4456
</phone>
<email hide="yes" />
</person>'''
tree = ET.fromstring(data)
print('Name:', tree.find('name').text)
print('Attr:', tree.find('email').get('hide'))
ii. Looping through nodes using XML
import xml.etree.ElementTree as ET
input = '''
<stuff>
<users>
<user x="2">
<id>001</id>
<name>Chuck</name>
</user>
<user x="7">
<id>009</id>
<name>Brent</name>
</user>
</users>
</stuff>'''

You might also like