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:
- A running Spark session configured with ArcGIS GeoAnalytics Engine.
- A notebook connected to your Spark session (e.g. Jupyter, JupyterLab, Databricks, EMR, etc.).
- An internet connection.
- An active AWS subscription.
- An S3 bucket that you can change permissions for.
Steps
Import and authorize
-
In your notebook, import
geoanalytics
and authorize the module using a username and password, or a license file.PythonUse dark colors for code blocks Copy 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
and AWS
environment variables or
another supported authentication method.
Once authentication is configured you can read and write to S3 using paths in the format S3
.
-
Write a DataFrame
df
to an S3 bucket as vector tiles. See Vector tiles for a detailed explanation of each option.PythonUse dark colors for code blocks Copy dataframe.write.format("vector-tile") \ .option("layerName", "vector_layer") \ .option("maxLevel", 3) \ .mode("overwrite") \ .save(r"s3a://vectortiles/result")
Visualize in ArcGIS Pro
-
Update the
vector-tile.json
file created with the vector tiles in S3. Thevector-tile.json
file is created with atiles
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 updatedtiles
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" ] -
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.
-
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.
-
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.
-
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
.