wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Geospatial Python libraries

Total questions: 60

Worksheet time: 47mins

Name
Class
Date
1.

What will the following code return? import numpy as np; np.array([1, 2, 3]).dtype

a)

int64

b)

float64

c)

list

d)

array

2.

How do you import the GeoDataFrame class from the geopandas library?

a)

from geopandas import GeoDataFrame

b)

import GeoDataFrame from geopandas

c)

import geopandas as gpd; gpd.GeoDataFrame

d)

from geopandas.GeoDataFrame import

3.

Which line of code correctly reads a shapefile into a GeoDataFrame using Geopandas?

a)

gpd.read_file('my_shapefile.shp')

b)

gpd.open('my_shapefile.shp')

c)

GeoDataFrame.read_file('my_shapefile.shp')

d)

gpd.load('my_shapefile.shp')

4.

Which function from rasterio is used to open and read raster data?

c)

rasterio.load()

d)

rasterio.get()

5.

How can you extract the X and Y coordinates of a point geometry in Geopandas? Assume gdf is a GeoDataFrame containing a Point geometry.*

a)

gdf.geometry.x, gdf.geometry.y

b)

gdf.x, gdf.y

c)

gdf['geometry'].x, gdf['geometry'].y

d)

. gdf.loc[:, 'geometry'].x, gdf.loc[:, 'geometry'].y

6.

What is the correct way to convert a GeoDataFrame to a JSON string

a)

gdf.to_json()

b)

gdf.to_string('json')

c)

gdf.export('json')

d)

json.dumps(gdf)

7.

Which GDAL/OGR function is used to read vector data formats?

8.

How do you plot a GeoDataFrame using Geopandas?

a)

gdf.plot_map()

b)

gdf.draw()

c)

gdf.plot()

9.

What is the correct syntax to reproject a GeoDataFrame to a new CRS in GeoPandas?

a)

gdf.set_crs('EPSG:4326')

b)

gdf.reproject('EPSG:4326')

c)

gdf.crs = 'EPSG:4326'

d)

gdf.to_crs('EPSG:4326')

10.

Which library function would you use to calculate the distance between two geographic points?

a)

geopy.distance.compute(point1, point2)

b)

geopy.distance.calculate(point1, point2)

c)

geopy.distance.measure(point1, point2)

d)

geopy.distance.distance(point1, point2)

11.

How do you save a raster file using Rasterio?

a)

with rasterio.save('output.tif', 'w', **profile) as dst: dst.write(array)

b)

with rasterio.open('output.tif', 'w', **profile) as dst: dst.write(array)

c)

with rasterio.create('output.tif', 'w', **profile) as dst: dst.write(array)

d)

rasterio.to_file('output.tif', 'w', **profile, array)

12.

Which function from Matplotlib would you use to show an image?

a)

plt.plot(image)

b)

plt.show(image)

c)

plt.imshow(image)

d)

plt.display(image)

13.

In PyProj, how do you define a projection using the EPSG code 4326?

a)

Proj('EPSG:4326')

b)

Projection('EPSG:4326')

c)

pyproj.Proj('+init=epsg:4326')

d)

pyproj.CRS('EPSG:4326')

14.

Which line of code correctly initializes an ipyleaflet Map?

a)

Map(center=[lat, lon], zoom=10)

b)

ipyleaflet.Map(center=[lat, lon], zoom=10)

c)

leaflet.Map([lat, lon], zoom=10)

d)

ipyleaflet.createMap(center=[lat, lon], zoom=10)

15.

How do you add a marker to a map in Folium?

a)

folium.Marker(location=[lat, lon]).add_to(map)

b)

map.addMarker([lat, lon])

c)

folium.addMarker(map, [lat, lon])

d)

Marker([lat, lon]).add_to(map)

16.

Which code snippet correctly opens a raster file using Rasterio?

a)

raster = open('example.tif', 'r')

b)

raster = rasterio.open('example.tif')

c)

raster = rasterio.load('example.tif')

d)

raster = rasterio.file('example.tif')

17.

In Geopandas, how do you calculate the area of each geometry in a GeoDataFrame called 'gdf"?

a)

gdf['area'] = gdf.area()

b)

gdf['area'] = gdf.calculate_area()

c)

gdf['area'] = gdf.geom.area()

d)

gdf['area'] = gdf.geometry.area

18.

Which PyQGIS method is used to add a vector layer?

a)

qgis.addLayer(path, name, 'vector')

b)

qgis.vectorLayer(path, name, 'ogr')

c)

iface.addVectorLayer(path, name, 'ogr')

d)

iface.loadLayer(path, name, 'vector')

19.

How do you install a geospatial library, say 'geopandas', using pip?

a)

install pip geopandas

b)

pip install geopandas

c)

pip get geopandas

d)

geopandas pip install

20.

What will the following code return? import shapely.geometry as geom; geom.LineString([(0, 0), (1, 1)]).length

a)

1.0

b)

1.414

c)

2

d)

0.5

21.

What is ArcPy primarily used for?

a)

Image processing

b)

Web development

c)

Geoprocessing within Esri ArcGIS environment

d)

Statistical analysis

22.

GeoPandas extends which library to work with spatial data?

a)

NumPy

b)

Pandas

c)

Matplotlib

d)

PyPlot

23.

Which library is used for translating between GIS formats and extensions?

a)

GDAL/OGR

b)

RSGISLib

c)

PyProj

d)

Fiona

24.

RSGISLib is a set of tools primarily used for what?

a)

Vector data manipulation

b)

Remote sensing and raster processing

c)

Web mapping

d)

Data cleaning

25.

What is the main purpose of the PyProj library?

a)

Data visualization

b)

Working with spatial referencing systems

c)

Machine learning

d)

Data scraping

26.

Which library is known for its array computing capabilities, often used in GIS for scientific computing?

a)

Scikit-learn

b)

NumPy

c)

Rasterio

d)

Fiona

27.

Matplotlib is a Python library used for what?

a)

Creating interactive web maps

b)

Performing geospatial data analysis

c)

Generating plots and visualizations

d)

Handling raster data

28.

Which library would you use to create interactive maps within a Jupyter Notebook?

a)

Folium

b)

ipyleaflet

c)

Geemap

d)

ArcPy

29.

What is the primary use of the ReportLab library in GIS?

a)

Data analysis

b)

Creating PDF reports

c)

Remote sensing

d)

Map production

30.

Folium library allows you to leverage which JavaScript library for web map visualizations?

a)

ReactJS

b)

D3.js

c)

Leaflet

d)

Vue.js

31.

Geemap is specifically designed for integration with which platform?

a)

ArcGIS Online

b)

Google Earth Engine

c)

OpenStreetMap

d)

Mapbox

32.

The LiDAR Python Package is used primarily for what type of data?

a)

Satellite imagery

b)

Light Detection and Ranging data

c)

Street map data

d)

Census data

33.

Scikit-learn is a library that allows for what kind of data processing in Python?

a)

Machine learning

b)

Data scraping

c)

Web development

d)

Geospatial data conversion

34.

What is the primary function of the pandas library in the context of GIS?

a)

Data manipulation and analysis

b)

Spatial data conversion

c)

Creating interactive maps

d)

Performing network analysis

35.

Which library would you use for object-based segmentation and classification in remote sensing?

a)

Geopandas

b)

RSGISLib

c)

ArcPy

d)

PyProj

36.

GDAL/OGR library supports how many raster and vector drivers, respectively?

a)

97 raster, 162 vector

b)

162 raster, 97 vector

c)

100 raster, 150 vector

d)

150 raster, 100 vector

37.

Which library is specifically designed for handling and analyzing raster data?

a)

Fiona

b)

Shapely

c)

Rasterio

d)

Geopandas

38.

Fiona is used with GeoPandas for what purpose?

a)

For overlay operations

b)

To handle spatial referencing systems

c)

For machine learning tasks

d)

To generate plots and visualizations

39.

ipyleaflet is a fusion of Jupyter Notebook and which library for interactive map visualizations?

a)

Leaflet

b)

D3.js

c)

OpenLayers

d)

Mapbox GL

40.

What is the main application of the NumPy library in geospatial analysis?

a)

Creating PDF reports

b)

Machine learning

c)

Scientific computing with array-based operations

d)

Web map visualizations

41.

Real-World Scenario:* You need to analyze satellite imagery to identify deforested areas. Which Python library would you primarily use?

a)

GeoPandas

b)

RSGISLib

c)

PyProj

d)

Folium

42.

How do you install the rasterio library in a Python environment

a)

install rasterio

b)

conda install rasterio

c)

pip install rasterio

d)

rasterio install

43.

You have a GeoDataFrame with multipolygon geometries and want to convert all geometries to polygons. Which method should you use?

a)

.to_polygon()

b)

.explode()

c)

.convert('Polygon')

d)

.dissolve()

44.

For creating an elevation profile from a digital elevation model (DEM), which Python library would be most suitable?

a)

Matplotlib

b)

GDAL

c)

PyProj

d)

Geopandas

45.

What is the correct way to plot a GeoDataFrame gdf that contains point geometries using GeoPandas?

a)

gdf.plot_point()

b)

gdf.plot(kind='point')

c)

gdf.plot(marker='o')

d)

gdf.plot_geometry()

46.

You need to find the distance between two points with latitudes and longitudes in a geodataframe. Which Python library helps you calculate this?

a)

Geopy

b)

Shapely

c)

Rasterio

d)

Fiona

47.

You are tasked with analyzing traffic flow patterns in an urban area using Python. Which library would you use for network analysis?

a)

NetworkX

b)

PySAL

c)

ArcPy

d)

Geopandas

48.

How would you change the CRS of a GeoDataFrame gdf to EPSG:4326 in GeoPandas?

a)

gdf.set_crs("EPSG:4326")

b)

gdf.to_crs(epsg=4326)

c)

gdf.reproject(4326)

d)

gdf.crs = "EPSG:4326"

49.

A city planner wants to overlay a GeoDataFrame of park locations with a GeoDataFrame of city regions to determine which parks are in which region. Which spatial operation would you use?

a)

Union

b)

Intersect

c)

Spatial Join

d)

Difference

50.

You're designing a Python script to automatically update and process incoming GIS data daily. Which feature should you implement to handle unexpected errors in the data?

a)

Logging

b)

Use of try-except blocks

c)

Hard-coding data corrections

d)

Ignoring errors with a pass statement

51.

Which function from Fiona is used to read data from a shapefile?

a)

Fiona.read_shapefile()

c)

open()

52.

You need to calculate the area of a lake represented as a polygon in a GeoDataFrame. Which GeoPandas attribute would you use to get the area?

a)

area

b)

calculate_area()

c)

get_area()

d)

size

53.

To display real-time data of a city's bus locations on a map on a website, which Python library would be most interactive and web-friendly?

a)

Geopandas

b)

Folium

c)

PyProj

d)

GDAL

54.

What is the correct syntax to convert a list of coordinates into a LineString using Shapely?

a)

LineString([list_of_coords])

b)

shapely.geometry.LineString(list_of_coords)

c)

LineString.create(list_of_coords)

d)

LineString.create(list_of_coords)

55.

You're analyzing climate data and need to handle both raster and vector data types. Which combination of libraries is most suitable?

a)

Rasterio and GeoPandas

b)

NumPy and Matplotlib

c)

Pandas and PyProj

d)

GDAL and Shapely

56.

A researcher wants to compare elevation data from two different time periods to study glacier melting. Which library would help process the raster data?

a)

PyProj

b)

Rasterio

c)

Geopandas

d)

Fiona

57.

How do you create a buffer of 10 units around a point geometry in Shapely?

a)

point.buffer(10)

b)

Buffer(point, 10)

c)

point.create_buffer(10)

d)

shapely.buffer(point, 10)

58.

You are given a set of polygons representing park boundaries and need to find the park with the largest area. Which GeoPandas method helps you identify it?

a)

max(gdf['area'])

b)

gdf['area'].max()

c)

gdf.max('area')

d)

max_area(gdf)

59.

In an urban study, you need to calculate the shortest path between two points in a road network. Which Python library should you use?

a)

GeoPandas

b)

NetworkX

c)

RSGISLib

d)

PyProj

60.

How do you save a GeoDataFrame gdf to a new shapefile called 'output.shp'?

a)

gdf.to_file('output.shp')

b)

gdf.save('output.shp')

c)

gdf.export('output.shp')

d)

gdf.write('output.shp')