Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Student Name

Course

Institution Affiliation

Instructor

Date
DATA SOURCE :

The OpenStreetMap (OSM) dataset is a collaborative project to create a free and open-source

map of the world. The dataset contains geospatial data about various features such as roads,

buildings, points of interest, land use, and natural features. The OSM dataset is maintained by a

large and diverse community of contributors worldwide, who use various techniques to collect

and update the data.

The data in OSM is stored in a database, which is organized into nodes, ways, and relations. A

node is a single point in space with a latitude and longitude coordinate, representing a feature

such as a building entrance or a street lamp. A way is a series of connected nodes representing a

linear feature such as a road or a river. A relation is a collection of nodes, ways, and other

relations representing a complex feature such as a building or a multi-level interchange.

Query 1: Mapping the Educational Landscape: Spatial Analysis of Schools in New

York City

Objective and Type of Analysis

The objective here is to retrieve the location data for all schools with a name value present in the

New York City area. Converting the raw geometric data into human-readable representations

facilitates easier manual review and interpretation without needing GIS software.

SQL Query Code

SELECT ST_AsText(way), name AS school_name, amenity

FROM planet_osm_point

WHERE amenity = 'school' AND name IS NOT NULL;


SQL Code Actions and Components

SELECT ST_AsText(way), name AS school_name, amenity:

ST_AsText(way) applies the Spatial Text function to the way column which contains the

geographic point coordinates. This converts them into a well-formatted string representation

using the WKT (Well Known Text) format.

Renaming name to school_name makes the output column label more descriptive.

Selecting amenity retains the categorization of these features as schools.

FROM planet_osm_point:

Planet_osm_point contains geographic elements represented as points, including the school

locations being targeted. It serves as the datasource.

WHERE amenity = 'school' AND name IS NOT NULL:

Filters restrict outputs to only point features classified as amenities of type 'school' with a name

value present (non-null). This isolates actual named schools.


Results Analysis:

The retrieved location data for schools in the New York City area, presented in human-readable

format, reveals key details about various educational institutions. Notable entries include Apple

Montessori School, Plaza Child Care School, Peppermint Tree Child Care Center School, Sacred

Heart Elementary School, Saint Mary Elementary School, and Cardinal McCarrick High School.

The spatial coordinates, provided in the POINT(x y) format, accurately depict the geographic

positions of each school. The amenity type 'school' categorizes these locations, offering valuable

insights into the distribution of educational facilities. Stakeholders, including educators, parents,

and city planners, can leverage this information to assess the accessibility and geographic

coverage of educational institutions, aiding in strategic decision-making related to educational

infrastructure.
Query 2: Decoding New York City's Post Offices: Utilizing Spatial Functions for

Location Analysis

Objective and Type of Analysis

The goal of this query is to extract the geographic locations of all post office amenities with a

name value in the New York City region from the planet_osm_point database. Applying the

ST_AsText spatial function converts the raw coordinate data into human-interpretable text

representations for easy analysis without needing GIS visualization software.

SQL Query Code

SELECT ST_AsText(way), name AS postoffice_name, amenity

FROM planet_osm_point

WHERE amenity = 'post_office' AND name IS NOT NULL;

SQL Code Actions and Components

SELECT ST_AsText(way), name AS postoffice_name, amenity

ST_AsText(way): Translates the way column containing geographic point coordinates into Well-

Known Text (WKT) format strings e.g. POINT(-74 40). This makes the raw coordinates

understandable.

name AS postoffice_name: Renames the name column to the more descriptive label

postoffice_name to distinguish extracted names as belonging to post offices.

amenity: Retains the classification amenity tag marking these map features as post offices.

FROM planet_osm_point
Specifies planet_osm_point table as the data source. This contains point geometries representing

real-world features like the post offices we want to extract.

WHERE amenity = 'post_office' AND name IS NOT NULL

Filters dataset to only points categorized as amenities of type 'post_office' which have a name

value present (non-null). Ensures only named post offices are selected.

Results Analysis:

The output presented the geographic coordinates and details of various post offices in the New

York City region. Notable entries include FedEx Customer Center, FedEx Office, United States

Post Office, Carteret Post Office, The UPS Store, and Clark Post Office. The spatial coordinates,
provided in the POINT(x y) format, accurately represent the locations of each post office. The

amenity type 'post_office' categorizes these locations, offering insights into the distribution of

postal services in the specified area. This dataset, with multiple rows, provides foundational

information for understanding the spatial layout of post offices. Stakeholders, including postal

service administrators, urban planners, and logistics professionals, can leverage this information

to assess accessibility, plan efficient service routes, and gain a nuanced understanding of the

postal infrastructure landscape in New York City. The spatial context enhances the usability of

the data, allowing for informed decision-making and strategic planning related to postal services.

Query 3:Navigating New York City: Analyzing the Distance Between Avatar Studios

and Times Square Subway Station

Objective

The goal is to find the real-world distance in meters between Avatar Studios and Times Square

station in New York City. This will tell us how many meters someone would need to walk in a

straight line on the ground between these places.

SQL Query Code

SELECT

'Avatar Studios' AS location1,

'Times Square' AS location2,

ST_DistanceSphere(

ST_SetSRID(

ST_MakePoint(
(SELECT ST_X(ST_Transform(way, 4326)) FROM planet_osm_point WHERE name

= 'Avatar Studios'),

(SELECT ST_Y(ST_Transform(way, 4326)) FROM planet_osm_point WHERE name

= 'Avatar Studios')

),

4326

),

ST_SetSRID(

ST_MakePoint(

(SELECT ST_X(ST_Transform(way, 4326)) FROM planet_osm_point WHERE name

= 'Times Square' AND public_transport = 'station'),

(SELECT ST_Y(ST_Transform(way, 4326)) FROM planet_osm_point WHERE name

= 'Times Square' AND public_transport = 'station')

),

4326

) AS distance_in_meters;

SQL Code Breakdown

Selecting the locations to label:

'Avatar Studios' AS location1

'Times Square' AS location2


This labels the output columns for the points of interest to make clear what each one represents

in the final distance measurement.

Finding the coordinates of Avatar Studios:

ST_X and ST_Y transform Avatar Studio's internal stored geometric data into readable latitude-

longitude values we can understand and measure between

Finding the coordinates of Times Square station:

Does the same coordinate transformations for the Times Square subway station entry point. The

filters ensure we only select the station point not other Times Square POIs.

Constructing point geometry objects:

ST_MakePoint uses the extracted real-world coordinates to create clean spatial point

representations for the distance calculation to use

ST_SetSRID sets the proper geographic coordinate system to longitude/latitude so the points

align correctly on the Earth's spherical surface

Calculating distance:

ST_DistanceSphere takes the two constructed point objects and calculates the geodesic meters

between them on the spheroid surface, giving us the real straight line distance someone would

walk.
Result Analysis

The query effectively calculates the distance between two pivotal locations in New York City,

Avatar Studios and the Times Square subway station, leveraging the ST_DistanceSphere

function to determine the great-circle distance in meters. The output presents this calculated

distance alongside the names of the locations, offering valuable spatial insights for various

applications.

This information is particularly useful for logistical planning, enabling optimization of routes

and efficient allocation of resources. For urban navigation, individuals can leverage the

computed distance to plan their journeys effectively, considering the spatial separation between

these significant landmarks. Additionally, from a broader geographic perspective, the data

contributes to a nuanced understanding of the city's layout and the relationships between key

locations.

You might also like