NEW
Font size
WorksheetsSection 1: Python and File Operations (Q1–10)
Total questions: 75
Worksheet time: 38mins
What is the purpose of os.makedirs(OUT_DIR, exist_ok=True)?
Deletes the directory
Creates OUT_DIR if it doesn't exist
Moves files into OUT_DIR
Renames the output directory
What does BASE = "/content/drive/MyDrive/Tree_Canopy" represent?
A Python package
Input image path
Base directory for I/O
TensorFlow variable
What happens when you run os.kill(os.getpid(), 9)?
Starts a new process
Saves the model
Terminates the Python process
Restarts Google Colab
Which module is used to mount Google Drive?
shutil
drive
google.colab
pathlib
What is the purpose of reproject() from rasterio.warp?
Clip raster
Plot raster
Align rasters to the same CRS and grid
Rename files
What does transform = src.transform retrieve?
File path
Coordinate transformation matrix
Image histogram
Projection WKT
What kind of data is crs = src.crs?
File size
Spatial resolution
Coordinate Reference System
Image filter
What is the output of src.read(1)?
A vector file
A scalar value
A 2D array (raster band)
An image preview
What type of file is Tree_Crowns2.gpkg?
JSON
GeoPackage
Text file
JPEG
What does CHM_PATH store?
3D building model
Filtered Canopy Height Model
Orthomosaic RGB
DEM
What is the purpose of subtracting DTM from DSM?
Detect roads
Generate CHM (Canopy Height Model)
Extract soil features
Calculate NDVI
Which unit is the CHM calculated in?
Inches
Feet
Meters
Pixels
Which library is used to open raster files?
geopandas
pandas
rasterio
shapely
What is the purpose of gaussian_filter()?
Normalize RGB
Detect edges
Smooth raster data
Compute histogram
What is a valid nodata handling technique?
Fill with ones
Replace with 0 only
Replace with np.nan
Ignore it
What does the features.shapes() function return?
Raster band
Polygon geometries from labeled regions
CHM histogram
Coordinate lists
Which Python library is used for vector data processing?
rasterio
fiona
geopandas
shapely
What does maximum_filter() detect in the CHM?
NDVI
Tree shadows
Local peaks (tree tops)
Water bodies
Which unit is crown area calculated in?
Pixels
Hectares
Square meters
Kilometers
What is watershed() used for in this context?
Predict water flow
Segment tree crowns
Clip DEM
Apply edge detection
What is the purpose of gdf_crowns["height_m"]?
Slope angle
Tree width
Max height per crown
What does rasterio.transform.xy() compute?
Polygon area
Real-world coordinates from row/col
Distance between points
Raster cell values
What does gpd.points_from_xy(xs, ys) create?
A raster file
Tree centroid points
Polygon features
Buffer zones
What does df_pts.to_csv() do?
Save shapefile
Save tree point data in CSV format
Export raster
Generate HTML
What is the minimum height used to detect trees?
0.5 m
1.0 m
2.0 m
5.0 m
Why is chm[chm < 0] = 0 used?
Apply smoothing
Resample image
Clean artifacts (negative height)
Remove low trees
What is PIX_M used for?
Count trees
Convert pixel to meters
Raster reclassification
Project image
What function detects tree tops based on CHM?
gaussian_filter
maximum_filter
uniform_filter
binary_closing
What does the expression NDVI = (NIR - R) / (NIR + R) calculate?
Soil composition
Vegetation health
Crown area
Height difference
Why is exg_mask = ExG >= EXG_THR used?
Segment buildings
Detect water
Create RGB mask for trees
Create a DTM
Which library is used for tree crown detection?
FastAI
DeepForest
XGBoost
PyTorch Lightning
What kind of model is DeepForest?
Semantic segmentation model
Object detection model
Clustering algorithm
Regression model
What type of image does DeepForest expect?
Grayscale
RGB (3 bands)
NDVI only
Hyperspectral
What does model.use_release() do?
Plot CHM
Load pretrained model
Segment crowns
Download custom weights
What does the predict_image() function return?
Points only
Bounding box detections
Loss value
Mask layer
What does the parameter DF_SCORE = 0.20 represent?
Batch size
Confidence score threshold
Height threshold
Number of classes
Which input is not required by DeepForest?
RGB image
CHM
Numpy array
RGB channels (3-band)
Which of the following is a DeepForest output?
Segmentation mask
Bounding box coordinates
Soil depth
Vegetation index
What kind of deep learning model underpins DeepForest?
UNet
RetinaNet
Transformer
KMeans
What is a common use case of DeepForest?
Urban planning
Tree crown detection in RGB orthomosaics
Climate forecasting
Sea temperature prediction
What type of file is Tree_Points2.csv?
Raster
Table with coordinates and tree attributes
Vector
Binary
What does Tree_Crowns2.gpkg contain?
NDVI layers
Bounding boxes
Which field is not in the tree points CSV?
tree_id
X
canopy type
height_m
What does the geometry column represent in GeoDataFrames?
Projection
CRS definition
Spatial features (points, polygons)
Color channels
What does the to_file() method save?
Raster
CSV
Vector geospatial data
Text log
What is the CRS used for in geospatial files?
Color Rendering Scheme
Coordinate Reference System
Compression Ratio Setting
Cell Raster Statistics
What format is typically used for raster data output?
.csv
.tif
.gpkg
.json
What does gdf_crowns["crown_area_m2"] = gdf_crowns.geometry.area calculate?
Average height
Area of each crown in m²
Bounding box
Crown ID
What library allows saving .gpkg files in Python?
rasterio
geopandas
pyproj
rasterstats
What does xy(transform, r, c) compute in rasterio?
Crown shape
Real-world X, Y from pixel row and column
Layer bounds
Image extent
What's the primary benefit of saving crowns as vector polygons?
Easy color rendering
Faster loading
Enables precise spatial analysis and overlay
Reduces size
Which tool is used to segment crowns from a raster?
DeepForest
Watershed algorithm
NDVI threshold
ExG
Why are small crown regions filtered out in the code?
To simplify output
To remove noise and artifacts
To merge crowns
For visualization
Which file contains individual tree heights and coordinates?
CHM.tif
DTM.tif
Tree_Crowns2.gpkg
Tree_Points2.csv
What is the role of MIN_CROWN_M2 in tree crown analysis?
Tree height cap
Minimum crown area to retain the crown
Minimum NDVI
Minimum EVI
Why is count = src.count important in raster analysis?
Gives projection info
Returns number of bands in the raster
Gives pixel size
Outputs file format
What happens if an image has fewer than 3 bands?
Script continues
DeepForest throws a ValueError
Image is converted
Bands are duplicated
How are tree IDs assigned in GeoDataFrame?
By GPS
Sequential integers starting from 1
By height
Based on filename
What is the result of gdf_pts.merge(gdf_crowns, on="tree_id")?
It converts vector to raster
Joins point and crown attributes by tree ID
Clips raster to crown
Detects new crowns
What determines the window size for maximum_filter()?
NDVI
Crown diameter and pixel size
DSM range
CHM extent
Which formula is used for NDVI?
(NIR - Red) / (NIR + Red)
(Green - Red) / (Green + Red)
(Blue - Green) / (Blue + Green)
Red / Green
What is NDVI used for in this script?
Height thresholding
Vegetation masking
RGB compositing
Soil detection
What is used when NIR is not available?
Excess Green Index (ExG)
NDMI
RGB-D fusion
EVI only
What is the threshold for NDVI_MIN in this script?
0.5
0.25
0.15
0.75
Which bands are required to calculate EVI?
Green, Blue
NIR, Red, Blue
Red only
Blue only
What type of mask is created using NDVI + EVI?
Slope mask
Strong vegetation mask
CHM mask
Erosion mask
Why is evi_denom[evi_denom == 0] = 1e-6 used?
To maximize NDVI
To avoid division by zero
To smooth the EVI
To normalize pixel values
What is the unit of the RGB bands used in DeepForest?
0–1 range
0–255 pixel values
Geodetic degrees
Meters
What happens when RGB.max() <= 1.0?
Convert to binary
Ignore values
Scale up to 0–255 range
Clip to 0–1
Why does the script check veg_mask.shape == chm_s.shape?
Check CRS
Ensure both arrays can be AND-ed safely
Filter ExG
Align DEM
Why is a smoothing step used after CHM generation?
Remove all peaks
Reduce noise for peak detection
Make raster smaller
Reproject CRS
What does GAUSS_SIGMA_PX = 2.0 control?
NDVI scale
Smoothing intensity of CHM
Band blending
Projection units
What is the default threshold for tree detection score?
0.75
0.20
1.0
0.0
Which variable limits how large a crown can be?
MIN_CROWN_M2
MAX_CROWN_M2
GAUSS_SIGMA_PX
PEAK_MIN_HEIGHT
What is the output of watershed(-chm_s, markers, mask)?
Raster image
Labeled crown segments
Binary mask
