May 5, 2023

What Are Snowflake Geospatial Data Types?

By Justin Delisi

Utilizing location-based data sets to generate visual analysis has become essential to both businesses and governments. Almost all organizations process data that has some sort of spatial component, be it shipping routes, customer buying patterns, or even weather patterns. 

Historically, a challenge for data engineers and data scientists has been how to efficiently store and query this information effectively to gain the insights the business needs. 

In response to this need, the Snowflake Data Cloud has developed geospatial data types in order to take the guesswork out of working with location-based data. 

In this post, we’ll explain what the Snowflake geospatial data types are, how using geospatial data can benefit your organization, and some frequently asked questions involving geospatial data.

What is the Geospatial Feature in Snowflake?  

Geospatial data is information that describes features with a corresponding location on the Earth or in a planar (Euclidean, Cartesian) coordinate system. Location data on Earth comes in the form of latitude and longitude (and occasionally altitude), whereas planar data is represented by x and y coordinates.

Snowflake has the following two geospatial data types to be used with location data:

  • GEOGRAPHY
    • Models the Earth as if it were a perfect sphere
    • Points are represented by degrees of latitude and longitude
    • Altitude is not currently supported
    • Current geospatial data you may have (e.g., longitude and latitude data points, WKT, WKB, GeoJSON, etc.) can be converted into GEOGRAPHY to improve query performance significantly
  • GEOMETRY
    • Represents features in a planar coordinate system
    • Coordinates are represented by pairs of real numbers (x,y)
    • Units of x and y are determined by the spatial reference system (SRS)  associated with the geometry object
      • The spatial reference system identifier (SRID) can be set by using the built-in function ST_SETSRID
 

Snowflake provides a set of geospatial functions for both GEOMETRY and GEOGRAPHY. The following are some of the most useful functions:

  • TO_GEOMETRY/TO_GEOGRAPHY
    • Converts a set of values to geometry or geography
  • ST_XMAX/ST_YMAX
    • Returns the maximum longitude/X coordinate (or in the case of YMAX, the maximum latitude/Y coordinate) of a GEOGRAPHY or GEOMETRY object
  • ST_AREA
    • Returns the area of the polygon(s) in a GEOGRAPHY or GEOMETRY object
  • ST_DISTANCE
    • Returns the minimum geodesic distance between two GEOGRAPHY or the minimum Euclidean distance between two GEOMETRY objects
  • ST_SIMPLIFY
    • Returns an approximation of a geography or geometry object that represents a line or polygon
    • Removes vertices from the line/polygon to return a more generalized shape
 

The full list of geospatial functions can be found here.

When Should You Use Geospatial Data Types? 

Location-based data can be a great asset to an organization, but it’s not for everyone. Historically, it’s most often used in scientific or government contexts, but commercial applications have been growing as of late.

The following are some examples of commercial use cases for location-based data:

Logistics and Supply Chain Management

Geospatial data can be used to optimize your delivery routes, track shipments, and monitor inventory levels. This helps your company reduce costs, improve efficiency, and increase customer satisfaction. Geospatial data also allows companies that are expanding to better target their expansion efforts to grow their business more efficiently.

Real Estate and Property Management

Geospatial data can be used to analyze property values, assess risk, and identify potential investment opportunities. It can also be used to manage properties and facilities, such as tracking maintenance needs or scheduling repairs. Geospatial data can even be used by agents to show potential buyers important information such as flood risks and land quality.

Agriculture and Forestry

Geospatial data can be used to analyze soil types, moisture levels, and other factors to optimize crop yields and prevent soil erosion. Farmers can use precise geospatial data to save fertilizer, determine weather patterns and collect information on their vegetation. It can also be used to monitor forest health and predict the risk of wildfires.

Urban Planning and Development

Geospatial data can be used to analyze land use patterns, transportation infrastructure, and population density to inform urban planning decisions.

It can also be used to monitor and manage urban services, such as waste management or emergency services.

Marketing and Advertising

Geospatial data can be used to target advertising campaigns to specific geographic areas based on demographic data or other factors. It can also be used to analyze consumer behavior and preferences, such as identifying popular shopping or travel destinations.

With this information, retailers can create more personalized messaging to consumers, which has a significantly higher engagement rate than non-personalized messages.

Closing

Geospatial data is becoming a necessity for any business to gain a competitive advantage. With this rapidly growing type of data, Snowflake is at the forefront of technologies equipped to handle it. Snowflake makes it easy to take in geospatial data and visualize it, allowing your business to benefit. 

Interested in leveraging Geospatial data using Snowflake? Contact phData today for any questions, advice, best practices, or data strategy services.

Frequently Asked Questions

Geospatial data can be loaded similarly to any other type of data. The best practice for efficiency is to load your data in whatever format you currently use into a “raw” table, then convert said data into either GEOGRAPHY or GEOMETRY data types to be loaded into a new table. This will allow you to take advantage of the geospatial data types for query efficiency. For more information on how to load data into Snowflake, see our blog on the most popular methods for data ingestion in Snowflake.

Spatial data can refer to data for any kind of location, such as the layout of the human body, outer space, or the layout of a room. Geospatial data is a subset of spatial data, concentrating on features relating to locations on Earth.

Data Coach is our premium analytics training program with one-on-one coaching from renowned experts.

Accelerate and automate your data projects with the phData Toolkit