HomeBig DataGeospatial information lakes with Amazon Redshift

Geospatial information lakes with Amazon Redshift


Knowledge lake architectures assist organizations offload information from premium storage methods with out dropping the power to question and analyze the info. This structure may be helpful for geospatial information, the place builders might need terabytes of occasionally accessed information of their databases that they wish to cost-effectively keep. Nevertheless, this requires for his or her information lake question engine to help geographic info methods (GIS) information varieties and features.

Amazon Redshift helps querying spatial information, together with the GEOMETRY and GEOGRAPHY information varieties and features which might be utilized in querying GIS methods. Moreover, Amazon Redshift permits you to question geospatial information each in your information lakes on Amazon S3 and your Redshift information warehouse, providing you with the selection of how one can entry your information. Moreover, AWS Lake Formation and help for AWS Identification and Entry Administration (IAM) in Esri’s ArcGIS Professional provides you a approach to securely bridge information between your geospatial information lakes and map visualization instruments. You possibly can arrange, handle, and safe geospatial information lakes within the cloud with a couple of clicks.

On this submit, we stroll by the right way to arrange a geospatial information lake utilizing Lake Formation and question the info with ArcGIS Professional utilizing Amazon Redshift Serverless.

Answer overview

In our instance, a county public well being division has used Lake Formation to safe their information lake that comprises public well being info (PHI) information. Epidemiologists inside the county wish to create a map for the clinics offering vaccination for his or her communities. The county’s GIS analysts want entry to the info lake to create the required maps with out with the ability to entry the PHI information.

This resolution makes use of Lake Formation tags to permit column-level entry within the database to the general public info that features the clinic names, addresses, zip codes, and longitude/latitude coordinates with out permitting entry to the PHI information inside the similar tables. We use Redshift Serverless and Amazon Redshift Spectrum to entry this information from ArcGIS Professional, a GIS mapping software program from Esri, an AWS Accomplice.

The next diagram exhibits the structure for this resolution.

End-to-end architecture showing ArcGIS Pro data integration with AWS analytics services through Redshift connector

The next is a pattern schema for this submit.

Description Column Identify Geoproperty Tag
Affected person ID patient_id No
Clinic ID clinic_id Sure
Deal with of Clinic clinic_address Sure
Clinic Zip Code clinic_zip Sure
Clinic Metropolis clinic_city Sure
First Identify Affected person first_name No
Final Identify Affected person last_name No
Affected person Deal with patient_address No
Affected person Zip Code patient_zip No
Vaccination Sort vaccination_type No
Latitude of Clinic clinic_lat Sure
Longitude of Clinic clinic_long Sure

Within the following sections, we stroll by the steps to arrange the answer:

  1. Deploy the answer infrastructure utilizing AWS CloudFormation.
  2. Add a CSV with pattern information to an Amazon Easy Storage Service (Amazon S3) bucket and run an AWS Glue crawler to crawl the info.
  3. Arrange Lake Formation permissions.
  4. Configure the Amazon Redshift Question Editor v2.
  5. Arrange the schemas in Amazon Redshift.
  6. Create a view in Amazon Redshift.
  7. Create a neighborhood database person in ArcGIS Professional.
  8. Join ArcGIS Professional to the Redshift database.

Stipulations

It is best to have the next stipulations:

Arrange the infrastructure with AWS CloudFormation

To create the surroundings for the demo, full the next steps:

  1. Log in to the AWS Administration Console as an AWS account administrator and a Lake Formation information lake administrator—this account must be each an account admin and an information lake admin for the template to finish.
  2. Open the AWS CloudFormation console
  3. Select Launch Stack.

The CloudFormation template creates the next elements:

  • S3 bucketsamp-clinic-db-{ACCOUNT_ID}
  • AWS Glue databasesamp-clinical-glue-db
  • AWS Glue crawler samp-glue-crawler
  • Redshift Serverless workgroupsamp-clinical-rs-wg
  • Redshift Serverless namespacesamp-clinical-rs-ns
  • IAM position for Amazon Redshiftdemo-RedshiftIAMRole-{UNIQUE_ID}
  • IAM position for AWS Gluesamp-clinical-glue-role
  • Lake Formation tag geoproperty

Add a CSV to the S3 bucket and run the AWS Glue crawler

The following step is to create an information lake in our demo surroundings after which use an AWS Glue crawler to populate the AWS Glue database and replace the schema and metadata within the AWS Glue Knowledge Catalog.

The CloudFormation stack created the S3 bucket we are going to use in addition to the AWS Glue database and crawler. We now have supplied a fictious take a look at dataset that may characterize the affected person and scientific info. Obtain the file and full the next steps:

  1. On the AWS CloudFormation console, open the stack you simply launched.
  2. On the Sources tab, select the hyperlink to the S3 bucket.
  3. Select Add and add the CSV file (data-with-geocode.csv), then select Add.
  4. On the AWS Glue console, select Crawlers within the navigation pane.
  5. Choose the crawler you created with the CloudFormation stack and select Run.

The crawler run ought to solely take a minute to finish, and can populate a desk named clinic-sample-s3_ACCOUNT_ID with a fictious dataset.

  1. Select Tables within the navigation pane and open the desk the crawler populated.

You will note that the dataset comprises fields that include PHI and personally identifiable info (PII).

AWS Glue table 'clinic-sample_s3' schema definition with patient and clinic fields, input/output formats, and database properties

We now have a database arrange and the Knowledge Catalog populated with the schema and metadata we are going to use for the remainder of the demo.

Arrange Lake Formation permissions

On this subsequent set of steps, we display the right way to safe PHI information to take care of compliance and empower GIS analysts to work successfully. To safe the info lake, we use AWS Lake Formation. With a purpose to correctly arrange Lake Formation permissions, we have to collect particulars on how entry to the info lake is established.

The Knowledge Catalog supplies metadata and schema info that permits companies to entry information inside the information lake. To entry the info lake from ArcGIS Professional, we use the ArcGIS Professional Redshift connector, which permits a connection from ArcGIS Professional to Amazon Redshift. Amazon Redshift can entry the Knowledge Catalog and supply connectivity to the info lake. The CloudFormation template created a Redshift Serverless occasion and namespace and an IAM position that we are going to use to configure this connection. We nonetheless must arrange Lake Formation permissions in order that GIS analysts can solely entry publicly accessible fields and never these containing PHI or PII. We are going to assign a Lake Formation tag on the columns containing the publicly accessible info and assign permissions to the GIS analysts to permit entry to columns with this tag.

By default, the Lake Formation configuration permits Tremendous entry to IAMAllowedPrinciples; that is to take care of backward compatibility as detailed in Altering the default settings to your information lake. To display a safer configuration, we are going to take away this default configuration.

  1. On the Lake Formation console, select Administration within the navigation pane.
  2. Within the Knowledge Catalog settings part, be sure Use solely IAM entry management for brand new databases and Use solely IAM entry management for brand new tables in new databases are unchecked.

AWS Data Catalog settings interface showing unchecked IAM-only access control options for new databases and tables

  1. Within the navigation pane, beneath Permissions, select Knowledge permissions.
  2. Choose IAMAllowedPrincipals and select Revoke.
  3. Select Tables within the navigation pane.
  4. Open the desk clinic-sample-s3_ACCOUNT_ID and select Edit schema.
  5. Choose the fields starting with clinic_ and select Edit LF-Tags.
  6. The CloudFormation stack created a Lake Formation tag named geoproperty. Assign geoproperty as the important thing and true for the worth on all of the clinic_ fields, then select Save.

Subsequent, we have to grant the Amazon Redshift IAM position permission to entry fields tagged with geoproperty = true.

  1. Select Knowledge lake permissions, then select Grant.
  2. For the IAM position, select demo-RedshiftIAMRole-UNIQUE_ID.
  3. Choose geoproperty for the important thing and true for the worth.
  4. Below Database permissions, choose Describe, and beneath Desk permissions, choose Choose and Describe.

Configure the Amazon Redshift Question Editor v2

Subsequent, we have to carry out the preliminary configuration of Amazon Redshift required for database operations. We use an AWS Secrets and techniques Supervisor secret created by the template to ensure password entry is managed securely in accordance with AWS greatest practices.

  1. On the Amazon Redshift console, select Question editor v2.
  2. If you first begin Amazon Redshift, a one-time configuration for the account seems. For this submit, depart the choices default and select Configure account.

For extra details about these choices, discuss with Configuring your AWS account.

Redshift query editor configuration interface with AWS KMS encryption settings and optional S3 bucket path input

The question editor would require credentials to hook up with the serverless occasion; these have been created by the template and saved in Secrets and techniques Supervisor.

  1. Choose Different methods to attach, then choose AWS Secrets and techniques Supervisor.
  2. For Secret, choose (Redshift-admin-credentials).
  3. Select Save.

Redshift connection interface displaying IAM Identity Center and AWS Secrets Manager authentication methods with credential selector

Arrange schemas in Amazon Redshift

An exterior schema in Amazon Redshift is a characteristic used to reference schemas that exist in exterior information sources. For info on creating exterior schemas, see Exterior schemas in Amazon Redshift Spectrum. We use an exterior schema to supply entry to the info lake in Amazon Redshift. From ArcGIS Professional, we are going to connect with Amazon Redshift to entry the geospatial information.

The IAM position used within the creation of the exterior schema must be related to the Redshift namespace. This has already been arrange by the CloudFormation template, nevertheless it’s a superb follow to confirm that the position is ready up accurately earlier than continuing.

  1. On the Redshift Serverless console, select Namespace configuration within the navigation pane.
  2. Select the namespace (sample-rs-namespace).

Amazon Redshift Serverless console displaying namespace configuration with status, workgroup and creation details

On the Safety and encryption tab, it is best to see the IAM position created by CloudFormation. If this position or the namespace isn’t current, confirm the stack in AWS CloudFormation earlier than continuing.

  1. Copy the ARN of the position to be used in a later step.

Redshift security configuration panel showing single synchronized IAM role with complete ARN and management options

  1. Select Question information to return to the question editor.

Amazon Redshift Serverless interface displaying sample-rs-namespace configuration with management and query data controls

  1. Within the question editor, enter the next SQL command; be sure you substitute the instance position ARN with your individual. This SQL command will create an exterior schema that makes use of the identical Redshift position related to our namespace to connect to the AWS Glue database.
CREATE EXTERNAL SCHEMA samp_clinic_sch_ext FROM DATA CATALOG
database 'sample-glue-database'
IAM_ROLE 'arn:aws:iam::{ACCOUNT_ID}:position/demo-RedshiftIAMRole-{UNIQUE_ID}';

  1. Within the question editor, carry out a choose question on sample-glue-database:

SELECT * FROM "dev"."samp_clinic_sch_ext"."clinic-sample_s3_{ACCOUNT_ID}";

As a result of the related position has been granted entry to columns tagged with geoproperty = true, solely these fields will likely be returned, as proven within the following screenshot (the info on this instance is fictionalized).

Query result displaying 20 medical clinics with details like name, address, and coordinates

  1. Use the next command to create a neighborhood schema in Amazon Redshift. The exterior schema can’t be up to date; we are going to use this native schema so as to add a geometry area with a Redshift perform.

CREATE SCHEMA samp_clinic_sch_local

Create a view in Amazon Redshift

For the info to be viewable from ArcGIS Professional, we might want to create a view. Now that the schemas have been established, we will create the view that may be accessed from ArcGIS Professional.

Amazon Redshift supplies many geospatial features that can be utilized to create views with fields utilized by ArcGIS Professional so as to add factors onto a map. We are going to use certainly one of these features as a result of the dataset comprises latitude and longitude.

Use the next SQL code within the Amazon Redshift Question Editor to create a brand new view named clinic_location_view. Substitute {ACCOUNT_ID} with your individual account ID.

CREATE
OR REPLACE VIEW "samp_clinic_sch_local"."clinic_location_view" AS
SELECT
    clinic_id as id,
    clinic_lat as lat,
    clinic_long as lengthy,
    ST_MAKEPOINT(lengthy, lat) as geom
FROM
    “dev”."samp_clinic_sch_ext"."clinic-sample_s3_{ACCOUNT_ID}"
WITH NO SCHEMA BINDING;

The brand new view that’s created beneath your native schema could have a column named geom containing map-based factors that can be utilized by ArcGIS Professional so as to add factors throughout map creation. The factors on this instance are for the clinics offering vaccines. In a real-world state of affairs, as new clinics are constructed and their information is added to the info lake, their areas could be added to the map created utilizing this information.

Create a neighborhood database person for ArcGIS Professional

For this demo, we use a database person and group to supply entry for ArcGIS Professional shoppers. Enter the next SQL code into the Amazon Redshift Question Editor to create a database person and group:

CREATE USER dbuser with PASSWORD ‘SET_PASSWORD_HERE’;
CREATE GROUP esri_developer_group;
ALTER GROUP esri_developer_group ADD USER dbuser;

After the instructions are full, use the next code to grant permissions to the group:

GRANT USAGE ON SCHEMA samp_clinic_sch_local TO GROUP esri_developer_group;
ALTER DEFAULT PRIVILEGES IN SCHEMA samp_clinic_sch_local GRANT SELECT ON TABLES TO GROUP esri_developer_group;
GRANT SELECT ON ALL TABLES IN SCHEMA samp_clinic_sch_local TO GROUP esri_developer_group;

Join ArcGIS Professional to the Redshift database

With a purpose to add the database connection to ArcGIS Professional, you want the endpoint for the Redshift Serverless workgroup. You possibly can entry the endpoint info on the sample-rs-wg workgroup particulars web page on the Redshift Serverless console. The Redshift namespaces and workgroups are listed by default, as proven within the following screenshot.

Amazon Redshift Serverless namespace and workgroup status dashboard with performance metrics

You possibly can copy the endpoint within the Basic info part. This endpoint might want to modified; the :5439/dev will have to be eliminated when configuring the connector in ArcGIS Professional.

Amazon Redshift Serverless workgroup details showing configuration and connection information

  1. Open ArcGIS Professional with the mission file you wish to add the Redshift connection to.
  1. On the menu, select Insert after which Connections, Database, and New Database Connection.
  2. For Database Platform, select Amazon Redshift.
  3. For Server, insert the endpoint you copied (take away every part following .com from the endpoint).
  4. For Database, select your database.

Amazon Redshift Serverless connection settings with server, authentication, and database fields

In case your ArcGIS Professional consumer doesn’t have entry to the endpoint, you’ll obtain an error throughout this step. A community path should exist between the ArcGIS Professional consumer and the Redshift Serverless endpoint. You possibly can arrange the community path with Direct Join, AWS Website-to-Website VPN, or AWS Consumer VPN. Though it’s not beneficial for safety causes, you may as well configure Amazon Redshift with a publicly accessible endpoint. Make sure you seek the advice of your safety and community groups for greatest practices and coverage steerage earlier than permitting public entry to your Redshift Serverless occasion.

If a community path exists and also you’re having points connecting, confirm the safety group guidelines enable communication inbound out of your ArcGIS Professional subnet over the port your Redshift Serverless occasion is operating on. The default port is 5439, however you may configure a spread of ports relying in your surroundings; see Connecting to Amazon Redshift Serverless for extra info.

If connectivity is profitable, ArcGIS Professional will add the Amazon Redshift connection beneath Connection File Identify.

  1. Select OK.
  2. Select the connection to show the view that was created to incorporate geometry (clinic_location_view).
  3. Select (right-click) the view and select Add To Present Map.

ArcGIS Professional will add the factors from the view onto the map. The ultimate map displayed has the symbology edited to make use of pink crosses to characterize the clinics as an alternative of dots.

Professional GIS interface showing Houston metropolitan vaccination clinics with topographic base map, toolbars, and database connectivity

Clear up

After you’ve gotten completed the demo, full the next steps to scrub up your assets:

  1. On the Amazon S3 console, open the bucket created by the CloudFormation stack and delete the data-with-geocode.csv file.
  2. On the AWS CloudFormation console, delete the demo stack to take away the assets it created.

Conclusion

On this submit, we reviewed the right way to arrange Redshift Serverless to make use of geospatial information contained inside an information lake to boost maps in ArcGIS Professional. This method helps builders and GIS analysts use accessible datasets in information lakes and rework it in Amazon Redshift to additional enrich the info earlier than presenting it on a map. We additionally confirmed the right way to safe an information lake utilizing Lake Formation, crawl a geospatial dataset with AWS Glue, and visualize the info in ArcGIS Professional.

For extra greatest practices for storing geospatial information in Amazon S3 and querying it with Amazon Redshift, see Easy methods to partition your geospatial information lake for evaluation with Amazon Redshift. We invite you to go away suggestions within the feedback part.


In regards to the authors

Jeremy Spell is a Cloud Infrastructure Architect working with Amazon Internet Companies (AWS) Skilled Companies. He enjoys architecting and constructing options for purchasers. In his free time Jeremy makes Texas model BBQ, and spends time together with his household and church neighborhood.

Jeff Demuth is a options architect who joined Amazon Internet Companies (AWS) in 2016. He focuses on the geospatial neighborhood and is captivated with geographic info methods (GIS) and expertise. Exterior of labor, Jeff enjoys touring, constructing Web of Issues (IoT) functions, and tinkering with the newest devices.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments