You are on page 1of 10

National Park Visitation Analysis

Student Name

Course

Institution Affiliation

Instructor

Date
1. What are the total number of campsites, historical sites, trails, and parking areas in

Rocky Mountain National Park?

Information Sought

The goal is to retrieve the totals for different amenities - campsites, historical sites, trails, and

parking areas specifically within Rocky Mountain National Park. Quantitative aggregation

analysis will be applied using SQL counts and joins to calculate totals from the multiple data

sources.

SQL Query Code

SELECT nb.parkname, COUNT(*) AS campground_num, nrhp.nrhp_sites AS nrhp_num,

trail_number.trails AS trail_num, parkinglot.parking AS pk_lot_num

FROM nps_boundary AS nb JOIN nps_facilities AS nf ON ST_Contains(nb.geom, nf.geom),

(SELECT COUNT(*) AS nrhp_sites

FROM nps_boundary AS b JOIN nps_facilities AS f ON ST_Contains(b.geom, f.geom) JOIN

nrhp_points AS n ON ST_Contains(b.geom, n.geom)

WHERE b.parkname = 'Rocky Mountain' AND f.facility_type = 'Campground'

) AS nrhp,

(SELECT COUNT(*) AS trails

FROM park_trails

WHERE park_name = 'Rocky Mountain'

) AS trail_number,

(SELECT COUNT(*) AS parking

FROM parking_areas

WHERE park_name = 'Rocky Mountain'


) AS parkinglot

WHERE nb.parkname = 'Rocky Mountain' AND nf.facility_type =

'Campground' GROUP BY nb.parkname, nrhp_num, trail_num,

pk_lot_num;

SQL Code Explanation

SELECT nb.parkname, COUNT(*) AS campground_num, nrhp.nrhp_sites AS nrhp_num,

trail_number.trails AS trail_num, parkinglot.parking AS pk_lot_num:

Explanation: Initiates the selection of columns for the final result. It chooses the 'parkname',

counts the number of campgrounds ('campground_num'), counts the number of NRHP sites

('nrhp_num'), counts the number of trails ('trail_num'), and counts the number of parking lots

('pk_lot_num').

Purpose: Specifies the columns to be displayed in the final result, including counts for

campgrounds, NRHP sites, trails, and parking lots.

FROM nps_boundary AS nb JOIN nps_facilities AS nf ON ST_Contains(nb.geom, nf.geom):

Explanation: Specifies the source tables for the query, where 'nb' is an alias for the

'nps_boundary' table, and 'nf' is an alias for the 'nps_facilities' table. It performs a spatial join

using ST_Contains to link boundary geometries with facility geometries.

Purpose: Identifies the tables from which data will be retrieved and associates park boundaries

with facilities.

(SELECT COUNT(*) AS nrhp_sites ... ) AS nrhp, ...:


Explanation: Creates a subquery (derived table) named 'nrhp' to count NRHP sites for the

specified park ('Rocky Mountain') and facility type ('Campground').

Purpose: Provides a count of NRHP sites in the subquery for later use in the main query.

WHERE nb.parkname = 'Rocky Mountain' AND nf.facility_type = 'Campground':

Explanation: Implements conditions for filtering the data. It checks for the park name ('Rocky

Mountain') and facility type ('Campground') to narrow down the selection.

Purpose: Filters the data to include only campgrounds in the specified park.

GROUP BY nb.parkname, nrhp_num, trail_num, pk_lot_num;:

Explanation: Groups the results by 'parkname' and the aggregated counts for NRHP sites, trails,

and parking lots.

Purpose: Prepares the data for aggregation, ensuring that counts are calculated for each unique

park.

Results Analysis

The query results for Rocky Mountain National Park provide a comprehensive overview of key

amenities, including campgrounds, historical sites, trails, and parking areas. The park boasts 7

campgrounds, 175 National Register of Historic Places (NRHP) sites, 490 trails, and 133 parking

lots. This detailed breakdown offers valuable insights for both park management and prospective

visitors. Park authorities can leverage this information to strategically allocate resources, address

potential overcrowding concerns, and enhance overall infrastructure. For visitors, the dataset

allows for a personalized experience, enabling them to tailor their visit based on individual
preferences and interests. The significant number of NRHP sites suggests rich historical

exploration opportunities, while the extensive trail network caters to outdoor enthusiasts

Screenshot

2. How many unpaved roads are in Rocky Mountain, Great Smoky Mountain, AND
Grand Teton National Parks, and what are the total lengths of the roads?

Information Sought

The goal is to find the number and total length in kilometers of unpaved/non-asphalt roads across

3 national parks - Rocky Mountain, Great Smoky Mountains, and Grand Teton. This will

characterize accessibility via unpaved routes.

SQL Query Code

SELECT b.parkname, COUNT(*) AS road_num, SUM(r.shape_length)/1000 AS rd_length_km

FROM park_roads AS r, nps_boundary AS b


WHERE ST_Contains(b.geom, r.geom)

AND b.parkname in('Rocky Mountain', 'Great Smoky Mountain', 'Grand Teton')

AND rdsurface IN ('Native or Dirt', 'Gravel')

GROUP BY b.parkname;

SQL Code Explanation

SELECT b.parkname, COUNT(*) AS road_num, SUM(r.shape_length)/1000 AS rd_length_km:

Explanation: Initiates the selection of columns for the final result. It chooses the 'parkname',

counts the number of roads in each park ('road_num'), and calculates the total length of roads in

kilometers ('rd_length_km').

Purpose: Specifies the columns to be displayed in the final result, including counts and length

calculations.

FROM park_roads AS r, nps_boundary AS b:

Explanation: Specifies the source tables for the query, where 'r' is an alias for the 'park_roads'

table and 'b' is an alias for the 'nps_boundary' table.

Purpose: Identifies the tables from which data will be retrieved.

WHERE ST_Contains(b.geom, r.geom) AND b.parkname in('Rocky Mountain', 'Great Smoky

Mountain', 'Grand Teton') AND rdsurface IN ('Native or Dirt', 'Gravel'):

Explanation: Implements conditions for filtering the data. It checks if the geometry of the

boundary contains the geometry of the roads, limits the parks to 'Rocky Mountain', 'Great Smoky
Mountain', and 'Grand Teton', and includes only roads with surfaces of 'Native or Dirt' or

'Gravel'.

Purpose: Filters the data to include only relevant roads within specified parks and with specific

road surfaces.

GROUP BY b.parkname;:

Explanation: Groups the results by the 'parkname', ensuring that counts and length calculations

are performed for each unique park.

Purpose: Prepares the data for aggregation, ensuring that counts and lengths are calculated for

each unique park.

Results

The analysis of unpaved roads in the selected national parks reveals notable patterns. Grand

Teton National Park stands out with a substantial count of 490 unpaved roads, collectively

covering approximately 162.77 kilometers. Similarly, Great Smoky Mountain National Park

features 105 unpaved roads, accounting for a total length of about 92.99 kilometers. In contrast,

Rocky Mountain National Park exhibits a more modest number of 24 unpaved roads, totaling

around 26.49 kilometers. This information provides insights into the distribution and extent of

unpaved roads in these parks, offering valuable data for effective park management and

conservation efforts.

Screenshot
3. Which National Park has visitation larger than the average visitation of all four
National Parks in this database?

Information Sought

The goal is to determine which national parks have total annual visitors greater than the average
visitation across all parks in the database. This allows identifying the most popular parks by
attendance.

SQL Code

SELECT np_name, SUM(recreation_visitors+non_recreation_visitors)

AS visitors FROM np_visitation

GROUP BY np_name

HAVING SUM(recreation_visitors + non_recreation_visitors) > (SELECT

AVG(s.total_visitation)

FROM (SELECT np_name, SUM(recreation_visitors+non_recreation_visitors) AS

total_visitation FROM np_visitation

GROUP BY np_name) AS s);

SQL Code Explanation


SELECT np_name, SUM(recreation_visitors + non_recreation_visitors) AS visitors:

Explanation: Initiates the selection of columns for the final result. It chooses the 'np_name'

(national park name) and calculates the sum of recreation and non-recreation visitors, labeled as

'visitors'.

Purpose: Specifies the columns to be displayed, including the park name and the total number of

visitors.

FROM np_visitation:

Explanation: Specifies the source table for the query, which is 'np_visitation'.

Purpose: Identifies the table from which data will be retrieved.

GROUP BY np_name:

Explanation: Groups the results by 'np_name', meaning the aggregation will be done for each

unique national park.

Purpose: Prepares the data for aggregation, ensuring that the sum of visitors is calculated for

each unique national park.

HAVING SUM(recreation_visitors + non_recreation_visitors) > ...:

Explanation: Implements a condition to filter the grouped results. It includes only those parks

where the sum of recreation and non-recreation visitors is greater than the calculated average.

Purpose: Filters out parks with visitation below the average, identifying parks with higher-than-

average attendance.
SELECT AVG(s.total_visitation) FROM ... AS s:

Explanation: Subquery to calculate the average total visitation across all parks.

Purpose: Provides the average visitation as a reference for filtering in the main query.

Results

The query succeeded, revealing that 'Great Smoky Mountain' National Park attracts more annual

visitors than the average across all four parks in the dataset. With an impressive count of

824,684,974 visitors, this data underscores the park's popularity, positioning it as the most visited

compared to the dataset's average attendance. These insights are crucial for understanding visitor

patterns, aiding resource allocation, and informing strategic park management. The substantial

visitation numbers highlight 'Great Smoky Mountain' as a prominent destination, influencing

decisions on promotion, infrastructure, and conservation strategies.

You might also like