Host vector tiles on Amazon S3

Vector tiles can be hosted locally or in the cloud for visualization in a web application or a desktop application like ArcGIS Pro. Visualizing vector tiles in ArcGIS Pro is a convenient option if you have ArcGIS Pro installed and don't want or need to create a web application to view your vector tiles with. This tutorial shows how to write vector tiles to a bucket in AWS S3 and then visualize them in ArcGIS Pro.

Prerequisites

To complete the following steps, you will need:

  1. A running Spark session configured with ArcGIS GeoAnalytics Engine.
  2. A notebook connected to your Spark session (e.g. Jupyter, JupyterLab, Databricks, EMR, etc.).
  3. An internet connection.
  4. An active AWS subscription.
  5. An S3 bucket that you can change permissions for.

Steps

Import and authorize

  1. In your notebook, import geoanalytics and authorize the module using a username and password, or a license file.

    Python
    Use dark colors for code blocksCopy
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    import geoanalytics
    geoanalytics.auth(username="user1", password="p@ssword")
    

Write your vector tiles to an S3 bucket

You must authenticate with S3 to read or write from a non-public bucket using the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables or another supported authentication method. Once authentication is configured you can read and write to S3 using paths in the format S3://bucket.

  1. Write a DataFrame df to an S3 bucket as vector tiles. See Vector tiles for a detailed explanation of each option.

    Python
    Use dark colors for code blocksCopy
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    dataframe.write.format("vector-tile") \
    		 .option("layerName", "vector_layer") \
    		 .option("maxLevel", 3) \
    		 .mode("overwrite") \
    		 .save(r"s3a://vectortiles/result")

Visualize in ArcGIS Pro

  1. Update the vector-tile.json file created with the vector tiles in S3. The vector-tile.json file is created with a tiles property which is empty. It looks like the following:

    "tiles" : ["{z}/{y}/{x}.pbf" ]

    You need to download the file and upload a new vector-tile.json with an updated tiles property. For example, if the vector tiles result is contained in a folder with name “result” and you are uploading to a bucket with name “vectortiles”, the path in the updated file will look similar to:

    "tiles" : ["https://vectortiles.s3.us-west-2.amazonaws.com/result/{z}/{y}/{x}.pbf" ]

  2. Update the S3 bucket’s permissions.

    In the S3 console, click on the bucket you wrote vector-tiles to and go to the Permissions tab.

    1. Under Block public access (bucket settings), click Edit and uncheck the last two options shown below:

      • Block public access to buckets and objects granted through new public bucket or access point policies.
      • Block public and cross-account access to buckets and objects through any public bucket or access point policies.

      The above will allow public access to your bucket. Keep in mind that your bucket is publicly accessible once you uncheck these two options. To learn more, see Access control block public access.

    2. Under Bucket policy, click Edit and provide a json file to enable GET access to your bucket:

      For more information and examples about access policies, see Access policy language overview. If it does not let you save your policy, you may need to update the bucket’s owner settings. For instructions, see S3 denied access policy.

    3. Under Cross-origin resource sharing (CORS), click Edit and provide a json file to enable CORS on your bucket. For more examples on how to configure CORS, see Enabling CORS examples.

You should now be able to view the vector tile result in ArcGIS Pro using the instructions provided in the Vector tiles core topic. You will need to reference the path to the vector-tile.json. In the above example, this would be https://vectortiles.s3.us-west-2.amazonaws.com/result/vector-tile.json.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.