Open In App

Determine a CRS is Projected or Not Using Python OSMnx projection Module

Last Updated : 15 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The coordinate reference system (CRS) is a framework that measures locations on the earth’s surface as coordinates. Geographic Coordinate Reference System uses latitude and longitude to specify a location on Earth (unit in degrees). On the other hand, the Projected Coordinate System employs a two-dimensional XY plane using northing (Y) and easting (X) values in meters. Northing is the distance from the equator, and easting is the distance from the central meridian (longitude).

Syntax of osmnx.projection.is_projected() Function

osmnx.projection.is_projected(crs)

Parameters: crs (string or pyproj.CRS) – the identifier of the coordinate reference system, which can be anything accepted by pyproj.CRS.from_user_input() such as an authority string or a WKT string

Returns: projected – True if crs is projected, otherwise False

Return Type: bool

Determine if a Coordinate Reference System is Projected or Not

In this example, using OSMnx, we fetch the street network data for Thiruvananthapuram, Kerala, and retrieve its coordinate reference system (CRS). Then, we determine whether the CRS is projected or not

Python3
import osmnx as ox

# load thiruvananthapuram city
place = "Thiruvananthapuram, Kerala"
G = ox.graph_from_place(place, network_type="drive")

# get crs
crs = G.graph['crs']
print("CRS-", crs)
# find projected or not
result = ox.projection.is_projected(crs)
print("Is Projected-", result)

Output

CRS- epsg:4326
Is Projected- False

Let’s use epsg:4146, geodetic coordinate system for India. In this example snippet, we specify the coordinate reference system (CRS) as “EPSG:4146,” which is a geodetic coordinate system for India. Then, using OSMnx, we determine whether this CRS is projected or not, and print the result accordingly.

Python3
import osmnx as ox

# area of use: India
crs = "EPSG:4146"
# find projected or not
result = ox.projection.is_projected(crs)
print("Is Projected-", result)

Output

Is Projected- False

In this example, we define the coordinate reference system (CRS) for Kerala as “EPSG:7781,” a projected coordinate system. Using OSMnx, we determine whether this CRS is projected or not, and print the result accordingly.

Python3
import osmnx as ox

# crs for kerala
crs = "epsg:7781"

# find projected or not
result = ox.projection.is_projected(crs)
print("Is Projected-", result)

Output

Is Projected- True

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads