How To Set Coordinate Reference Systems (CRS) In Snowflake Using Spatial Reference Identifiers

How To Set Coordinate Reference Systems (CRS) In Snowflake Using Spatial Reference Identifiers

In previous blogs, we’ve covered off what Coordinate Reference Systems (CRS) are, its scope and uses.

In this blog, we’ll cover how to set these on the Snowflake platform for geospatial referencing and analysis.

In Snowflake, you can define the Coordinate Reference System (CRS) by specifying a spatial reference identifier (SRID), which is a unique code that tells you which map or coordinate system you’re using, including its tolerance and resolution (or in other words, how precise and accurate it is).

TL;DR

If using the GEOGRAPHY data type in Snowflake, you won’t need to set the CRS, as it will be automatically set as WGS 84.

To set the CRS of a GEOMETRY data type, determine its SRID, then use the ST_SETSRID() function.

If not explicitly set, the SRID of a GEOMETRY column will be 0.

To convert from one CRS to another CRS on a GEOMETRY column, use the ST_TRANSFORM() function.

Overview

Coordinate Reference System

A Coordinate Reference System (CRS) defines how the two-dimensional, projected map in your GIS relates to real places on the earth. It encompasses:

  • Datum: Defines the position of the spheroid relative to the centre of the earth.
  • Projection: Converts the 3D surface of the earth to a 2D map.
  • Coordinate system: Defines how the coordinates relate to positions in the real world.

Spatial Reference System Identifier (SRID)

An SRID is a unique identifier associated with a CRS. It is a numeric value that references a specific CRS definition in a spatial database or standard, like the EPSG (European Petroleum Survey Group) codes.

Key Points

CRS is the comprehensive system that includes all the information needed to translate between coordinate systems and real-world positions.

SRID is an identifier for a specific CRS.

Example:
EPSG:4326 is a common SRID, where 4326 is the SRID that corresponds to the WGS 84 CRS (used by GPS).

What are the benefits of setting SRID in Snowflake?

Setting up an SRID in Snowflake ensures data consistency by aligning all spatial data to the same coordinate system, enhancing accuracy with precise tolerance and resolution information.

It facilitates interoperability between systems, enables advanced geospatial analysis and maintains data integrity by providing a defined coordinate framework.

This allows users to perform complex spatial queries efficiently in Snowflake.

How to set CRS and SRID in Snowflake

Snowflake provides the following data types for geospatial data:

  • The GEOGRAPHY data type, which models Earth as though it were a perfect sphere.
  • The GEOMETRY data type, which represents features in a planar (Euclidean, Cartesian) coordinate system.

The GEOGRAPHY data type follows the WGS 84 standard (spatial reference ID 4326).

The GEOMETRY data type represents features in a planar (Euclidean, Cartesian) coordinate system.

The coordinates are represented as pairs of real numbers (x, y). Currently, only 2D coordinates are supported.

The units of the X and Y are determined by the spatial reference system (SRS) associated with the GEOMETRY object. The spatial reference system is identified by the SRID number.

Unless the SRID is provided when creating the GEOMETRY object or by calling ST_SETSRID, the SRID is 0.

ST_SETSRID()

Returns a GEOMETRY object that has its SRID set to the specified value.

Use this function to change the SRID without affecting the coordinates of the object. If you also need to change the coordinates to match the new SRS, use ST_TRANSFORM instead.

ST_TRANSFORM()

Converts a GEOMETRY object from one spatial reference system SRS to another.

Use this function to change the SRID and the coordinates of the object to match the new SRS (spatial reference system).

If you just need to change the SRID without changing the coordinates (e.g. if the SRID was incorrect), use ST_SETSRID instead.

Syntax

ST_SETSRID( <geometry_expression> , <srid> )

Examples

The following example creates and returns a GEOMETRY object that uses the SRID 4326:

ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='EWKT';

SELECT ST_SETSRID(TO_GEOMETRY('POINT(13 51)'), 4326);

Syntax

ST_TRANSFORM( <geometry_expression> [ , <from_srid> ] , <to_srid> );

Examples
The following example transforms a POINT GEOMETRY object from EPSG:32633 (WGS 84 / UTM zone 33N) to EPSG:3857 (Web Mercator).

-- Set the output format to EWKT

ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='EWKT';

SELECT

ST_TRANSFORM(

ST_GEOMFROMWKT('POINT(389866.35 5819003.03)', 32633),

3857

) AS transformed_geom;

After setting the SRID on a GEOMETRY object, you can check if it has been applied correctly using the ST_SRID() function.

ST_SRID()

Returns the SRID (spatial reference system identifier) of a GEOGRAPHY or GEOMETRY object.

Currently, for any value of the GEOGRAPHY type, only SRID 4326 is supported and is returned.

Syntax

ST_SRID( <geography_or_geometry_expression> )

Examples
This shows a simple use of the ST_SRID function:

 

SELECT ST_SRID(ST_MAKEPOINT(37.5, 45.5));
+-----------------------------------+
| ST_SRID(ST_MAKEPOINT(37.5, 45.5)) |
|-----------------------------------|
| 4326 |

+———————————–+

Subscribe to our newsletter

Subscribe to receive the latest blogs and data listings direct to your inbox.

Read more from The Proptech Cloud

The Property Lifecycle

Discover the extensive property lifecycle and how it connects with other sectors. This infographic highlights the key phases and processes involved.

Why Is It So Difficult To Parse Addresses?

This blog explores what address parsing is and why it presents such unique challenges. Discover the intricacies behind address parsing and why getting it right is more complicated than it first appears.

How To Set Coordinate Reference Systems (CRS) In Snowflake Using Spatial Reference Identifiers

When working with geospatial data and mapping, you often need to specify the CRS for accurate and consistent spatial referencing and calculations. We guide you how.

Crafting a Storm Surge and Hurricane Risk Rating for Coastal Properties

A high-level approach to developing a storm surge and hurricane risk rating system to guide stakeholders with a vested interest in coastal properties.

How Proptech Is Revolutionising Real Estate

Proptech is the dynamic intersection of property and technology, and it’s reshaping real estate. And there’s still a huge potential for growth.

Coordinate Reference Systems (CRS) and Geodetic Datums: What’s the difference?

Coordinate Reference Systems (CRS) and Geodetic Datums: What’s the difference?

Coordinate Reference Systems (CRS) and geodetic datums are both used to represent the Earth’s surface, but they are different concepts, and importantly, serve different purposes. We provide definitions, highlight their differences and considerations for practical applications.

Coordinate Reference System (CRS)

A CRS is a coordinate-based system that provides a standardised framework for describing and locating points on the Earth’s surface. CRS is primarily used to represent specific locations on the Earth’s surface with precision and consistency.

A CRS can also be referred to as a spatial reference system (SRS) in many cases.

It defines a set of coordinates that can be used to represent the location of a point on the Earth’s surface.

A CRS typically includes a reference point (an origin), a set of axes (coordinate axes), and a unit of measurement (such as metres).

Geodetic Datum

A geodetic datum, on the other hand, is a mathematical model that defines the shape and size of the Earth’s surface, as well as the location of a reference point (the geodetic origin) and the orientation of the axes.

A geodetic datum provides the framework for measuring and comparing positions on the Earth’s surface.

It includes parameters describing the Earth’s ellipsoidal shape (semi-major and semi-minor axes), the flattening of the Earth, and the position of the datum origin.

Geodetic datums are essential for achieving high accuracy in geospatial measurements, especially over large areas.

What’s the difference?

While a CRS and a geodetic datum both provide frameworks for representing the Earth’s surface, they are different in their scope and purpose.

They serve distinct purposes in spatial representation and measurement.

The main differences between Coordinate Reference Systems and Geodetic Datums

Coordinate Reference Systems (CRS)Geodetic Datums
USESA CRS is used to represent the location of a point on the Earth's surfaceA geodetic datum is used to define the shape and size of the Earth's surface and the reference point used to measure positions
PRIMARY FOCUSA CRS deals primarily with coordinate systemA geodetic datum deals with the underlying shape and size of the Earth's reference ellipsoid
DEFINITIONSCRS definitions typically remain consistentGeodetic datums may evolve over time due to improvements in measurement techniques and advancements in geodesy
OPTIONSMultiple CRS are availableMultiple geodetic datums are available

It’s important to note that in many cases, CRSs are defined based on specific geodetic datums, ensuring compatibility and accuracy in spatial representations.

For example, the UTM system uses the WGS84 geodetic datum.

The decision between which CRS or geodetic datum to use

There are multiple choices of both CRS and geodetic datums available for users to select from.

The choice of CRS and geodetic datum depends on various factors such as the geographic region, application, and desired level of accuracy.

Geographic Region

Geographic Region

Different regions of the world may use specific CRS and geodetic datum combinations that are optimised for that region’s geographical characteristics.

Learn about the geodetic datums we use and reference in Australia.

Applications

Application

The type of application you’re working on can influence your choice of CRS and geodetic datum.

For example, surveying and mapping applications often require high accuracy, so a CRS and geodetic datum that offer precision are chosen. On the other hand, less accurate CRS and datum choices may be suitable for applications like general-purpose Geographic Information Systems or web mapping.

Accuracy

Desired Level of Accuracy

The level of precision required for a particular project or task is a crucial deciding factor. Some CRS and geodetic datum combinations are designed to provide centimetre-level accuracy, while others may provide accuracy at the metre or even decimetre level. So the choice really depends on the project’s specific accuracy requirements.

In practice, these above factors need to be carefully considered to ensure users choose the CRS and geodetic datum that is appropriate and aligns to their needs.

Considerations include whether it accurately represents geospatial data, can be integrated seamlessly with other data sources or used in specific analysis or modeling purposes. This will help avoid errors and inconsistencies in geospatial data handling and analysis.

Practical uses for CRS and geodetic datums

In practical terms, when working with geospatial data and mapping, you often need to specify both the CRS and the geodetic datum to ensure accurate and consistent spatial referencing and calculations. Keep in mind different geographic regions and applications may use specific datums and CRS to meet their needs, so understanding the distinction between them is essential for accurate geospatial referencing and analysis.

How to set these in Snowflake

If using a Geography data type the CRS used is WGS 84 and cannot be changed.

If using the Geometry data type, the CRS (or SRS) can be set with the ST_SETSRID function. To change the CRS of a geometry, use the ST_TRANSFORM function.

SELECT
ST_TRANSFORM(
ST_GEOMFROMWKT('POINT(389866.35 5819003.03)', 32633),
3857
) AS transformed_geom;

Read more from The Proptech Cloud

The Property Lifecycle

Discover the extensive property lifecycle and how it connects with other sectors. This infographic highlights the key phases and processes involved.

Why Is It So Difficult To Parse Addresses?

This blog explores what address parsing is and why it presents such unique challenges. Discover the intricacies behind address parsing and why getting it right is more complicated than it first appears.

How To Set Coordinate Reference Systems (CRS) In Snowflake Using Spatial Reference Identifiers

When working with geospatial data and mapping, you often need to specify the CRS for accurate and consistent spatial referencing and calculations. We guide you how.

Crafting a Storm Surge and Hurricane Risk Rating for Coastal Properties

A high-level approach to developing a storm surge and hurricane risk rating system to guide stakeholders with a vested interest in coastal properties.

How Proptech Is Revolutionising Real Estate

Proptech is the dynamic intersection of property and technology, and it’s reshaping real estate. And there’s still a huge potential for growth.

What is a Coordinate Reference System (CRS)?

What is a Coordinate Reference System (CRS)?

Imagine you’re a contestant on The Amazing Race or on a much smaller scale, playing treasure hunt, and are referencing a giant map. The map is the Earth, and you need to find specific locations. Now, to make sure you can find the next pit stop or treasures accurately, you need a set of rules for reading and describing locations on the map.

That set of rules is like a Coordinate Reference System (CRS).

A CRS defines how to assign coordinates (such as X and Y on a grid) to places on the map.

When there is a consistent way to find places on a map, everyone uses the same method to describe locations accurately.

Coordinate Reference System (CRS)

A Coordinate Reference System (CRS) is a system that uses numbers to precisely pinpoint locations on maps or the Earth’s surface, ensuring everyone uses the same rules for describing positions.

By defining sets of coordinates and a standardised framework, it offers a consistent way to specify locations, making it possible for maps and geographic data to be accurately interpreted and shared.

A CRS typically includes a reference point, a set of axes, and a unit of measurement.

What Purpose Does a CRS Serve?

CRS is primarily used to describe how coordinates are represented, mapped, and interpreted in a specific geographic or projected space. It is used for locating and referencing points on the Earth’s surface accurately.

CRS is used in geography (the study of the Earth’s landscapes, environments, places, and the relationships between people and their surroundings) and cartography (the design, production, and interpretation of maps, which are graphical representations of geographical information).

Different Types of CRS

  • Geographic CRS: Based on a spherical or ellipsoidal model of the Earth’s surface, commonly using latitude and longitude coordinates.
  • Projected CRS: Maps the three-dimensional spherical or ellipsoidal Earth onto a two-dimensional plane, such as a map or a flat surface. Examples include Universal Transverse Mercator (UTM) and State Plane Coordinate Systems.
  • Vertical CRS: Specifies elevations or depths relative to a reference surface (e.g., sea level).

Some examples of commonly used CRS include:

How CRS is Used in Property and Real Estate

Coordinate Reference Systems (CRS) play a crucial role in property and real estate in several ways:

  • Property Identification:
    CRS can be used to precisely locate and identify properties. Property boundaries, corners, and specific locations can be accurately described using coordinates, which is essential for legal and cadastral (land ownership) records.
  • Mapping and Surveying:
    Surveyors use CRS to create property surveys and maps. These maps are crucial for property transactions, boundary disputes, and construction projects. Accurate coordinates ensure that properties are properly defined.
  • Land Registration:
    When properties are bought or sold, accurate coordinates and CRS are used to update land registration records. This helps ensure the legality of property transactions and reduces the likelihood of property disputes.
  • Zoning and Planning:
    Urban and regional planners use CRS to map out zoning areas, plan infrastructure, and make decisions about land use. This information is crucial for developers, homeowners, and local governments.
  • Property Valuation:
    CRS can be used in property valuation models to assess the value of properties based on their location, proximity to amenities, and other geographic factors.
  • Real Estate Marketing:
    Real estate agents and online platforms often use mapping systems that rely on CRS to display property locations accurately. This makes it easier for buyers to understand the property’s surroundings.
  • Environmental Impact Assessment:
    When considering property development, CRS can be used to assess the potential environmental impact, taking into account factors like proximity to water bodies, floodplains, and protected areas.
  • Infrastructure Development:
    CRS is used in the planning and construction of transportation networks, utilities, and other infrastructure. It helps ensure that developments are located optimally and adhere to safety standards.
  • Disaster Risk Assessment:
    CRS is also essential in assessing properties’ vulnerability to natural disasters, such as floods or earthquakes. This information is vital for insurance purposes and disaster preparedness.

As you can see Coordinate Reference Systems (CRS) play a pivotal role in many facets of property and real estate management, and are used widely by proptechs.

Read more from The Proptech Cloud

The Property Lifecycle

Discover the extensive property lifecycle and how it connects with other sectors. This infographic highlights the key phases and processes involved.

Why Is It So Difficult To Parse Addresses?

This blog explores what address parsing is and why it presents such unique challenges. Discover the intricacies behind address parsing and why getting it right is more complicated than it first appears.

How To Set Coordinate Reference Systems (CRS) In Snowflake Using Spatial Reference Identifiers

When working with geospatial data and mapping, you often need to specify the CRS for accurate and consistent spatial referencing and calculations. We guide you how.

Crafting a Storm Surge and Hurricane Risk Rating for Coastal Properties

A high-level approach to developing a storm surge and hurricane risk rating system to guide stakeholders with a vested interest in coastal properties.

How Proptech Is Revolutionising Real Estate

Proptech is the dynamic intersection of property and technology, and it’s reshaping real estate. And there’s still a huge potential for growth.