Google Cloud Dataproc is a fully managed and highly scalable service for running Apache Spark and other open-source tools and frameworks. Using the steps outlined below, GeoAnalytics Engine can be leveraged within a PySpark notebook hosted in Google Dataproc.
GeoAnalytics Engine | Google Dataproc |
---|---|
1.0.x | 2.0-debian10, 2.0-ubuntu18, 2.0-rocky8 |
1.1.x - 1.3.x | 2.0-debian10, 2.0-ubuntu18, 2.0-rocky8, 2.1-debian11, 2.1-ubuntu20, 2.1-rocky8 |
1.4.x | 2.0-debian10, 2.0-ubuntu18, 2.0-rocky8, 2.1-debian11, 2.1-ubuntu20, 2.1-rocky8, 2.2-debian12, 2.2-ubuntu22, 2.2-rocky9 |
GeoAnalytics Engine | Google Dataproc Serverless for Spark |
---|---|
1.4.x | 1.1 LTS, 1.2 LTS, 2.0, 2.2 LTS |
To complete this install you will need:
- An active subscription to Google Cloud Platform
-
GeoAnalytics Engine install files. If you have a GeoAnalytics Engine subscription with a username and password, you can download the ArcGIS GeoAnalytics Engine distribution here after signing in. If you have a license file, follow the instructions provided with your license file to download the GeoAnalytics Engine distribution.
-
A GeoAnalytics Engine subscription, or a license file.
Prepare the workspace
-
Log in to the Google Cloud Console.
-
Select an existing project or set-up a new one.
-
Create a Google Cloud Storage bucket in the same region you plan to deploy a cluster in.
-
Upload the GeoAnalytics Engine
.jar
file and.whl
file to your bucket. Depending on the analysis you will complete, optionally upload the following jars:esri-projection-geographic
, if you need to perform a transformation that requires supplementary projection data.geoanalytics-natives
to use geocoding or network analysis tools.
-
Copy and paste the text below into a text editor and save it as a .sh script. Replace
<bucket-name
,> <jar-file-name
, and> <wheel-file-name
with the paths to the bucket name, the jar file name, and the wheel name from step 4. Save the script and upload it to your bucket.> Use dark colors for code blocks Copy #!/bin/bash BUCKET_NAME=<bucket-name> JAR_FILE=<jar-file-name> WHL_FILE=<wheel-file-name> WHL_PATH="gs://${BUCKET_NAME}/${WHL_FILE}" JAR_PATH="gs://${BUCKET_NAME}/${JAR_FILE}" tmpdir=$(dirname $(mktemp -u)) gsutil cp "${JAR_PATH}" "/usr/lib/spark/jars" gsutil cp "${WHL_PATH}" "${tmpdir}" #https://github.com/GoogleCloudDataproc/initialization-actions/blob/master/python/pip-install.sh set -exo pipefail readonly PACKAGES="${tmpdir}/${WHL_FILE}" function err() { echo "\[$(date +'%Y-%m-%dT%H:%M:%S%z')\]: $\*" exit 1 } function run_with_retry() { local -r cmd=("$@") for ((i = 0; i < 10; i++)); do if "${cmd[@]}"; then return 0 fi sleep 5 done err "Failed to run command: ${cmd\[*]}" } function install_pip() { if command -v pip \>/dev/null; then echo "pip is already installed." return 0 fi if command -v easy_install \>/dev/null; then echo "Installing pip with easy_install..." run_with_retry easy_install pip return 0 fi echo "Installing python-pip..." run_with_retry apt update run_with_retry apt install python-pip -y } function main() { if \[\[ -z "${PACKAGES}" \]\]; then echo "ERROR: Must specify PIP PACKAGES. A space separated list of packages to install. Packages can contain version selector" exit 1 fi install_pip run_with_retry pip install --upgrade ${PACKAGES} } main
If you need to perform a transformation that requires supplementary projection data, add the first line in the example below to the script and replace
PROJECTION
with the corresponding File API path noted in step 3. Follow these steps for every_DATA _JAR _PATH esri-projection-geographic
jar that you previously uploaded.If you are planning to use geocoding or network analysis tools, add the second line in the example below to the script and replace
GEOANALYTICS
with the corresponding File API path noted in step 3._NATIVES _JAR _PATH Use dark colors for code blocks Copy gsutil cp "${PROJECTION_DATA_JAR_PATH}" "/usr/lib/spark/jars" gsutil cp "${GEOANALYTICS_NATIVES_JAR_PATH}" "/usr/lib/spark/jars"
Create a cluster
-
Navigate to Google Dataproc and open the Dataproc Create a cluster page. If prompted, choose to create a cluster on Compute Engine.
-
Choose a Name, Location, Cluster Type, and Autoscaling policy that meet your requirements.
-
Under Versioning, choose a supported Google Dataproc image.
-
Under Component Gateway select "Enable component gateway".
-
Select any Optional components you may require. You must select at least either "Jupyter Notebook" or "Zeppelin Notebook".
-
Click Configure nodes and update the Master node and Worker node configurations to meet your requirements. Change other settings as needed.
-
Click Customize cluster and adjust the settings for Network configuration, Internal IP only, Dataproc Metastore, and Labels or keep the defaults.
-
Add the three properties in the table below to Cluster properties:
Prefix Key Value spark spark.plugins com.esri.geoanalytics.Plugin spark spark.serializer org.apache.spark.serializer.KryoSerializer spark spark.kryo.registrator com.esri.geoanalytics.KryoRegistrator -
Under Initialization actions, browse to the .sh script you uploaded previously and select it as the Executable file.
-
Adjust any remaining settings in Customize cluster as needed or keep the defaults.
-
Adjust any settings within the Manage security page or keep the defaults.
-
Click Create to create the cluster.
(Optional) Check cluster status and view logs
-
If the cluster is successfully created, you should see that the status of the cluster you just created in the Google Dataproc clusters page shows as Running.
-
If cluster creation failed, you should see the status of the cluster shows as Error. To view cluster logs and understand failure reasons:
- Click the cluster name on the Clusters page in Google Dataproc to open the Cluster details page.
- Click on view logs next to Cluster details. This will open up the Cloud Explorer page that
allows you to make a query selection to view a certain level of the Cluster logs. Usually you can start with querying
ERROR
level logs to get the error messages. To look for master daemon logs, worker daemon nodes, and system logs, filter with the log names indicated in the Dataproc documentation. - If you would like to access logs through other methods such as gcloud logging and logging API, see dataproc documentation on accessing cluster logs in Cloud logging.
Authorize GeoAnalytics Engine
-
Find the Web Interfaces page on the cluster you created previously. Open a Jupyter, JupyterLab, or Zeppelin notebook by clicking on the corresponding Component gateway.
-
Import the geoanalytics library and authorize it using your username and password or a license file. See Authorization for more information. For example:
Use dark colors for code blocks Copy import geoanalytics geoanalytics.auth(username="User1", password="p@ssw0rd")
-
Try out the API by importing the SQL functions as an easy-to-use alias like
ST
and listing the first 20 functions in a notebook cell:Use dark colors for code blocks Copy from geoanalytics.sql import functions as ST spark.sql("show user functions like 'ST_*'").show()
What’s next?
You can now use any SQL function, track function, or analysis tool in the geoanalytics
module.
See Data sources and Using DataFrames to learn more about how to access your data from your notebook. Also see Visualize results to get started with viewing your data on a map. For examples of what else is possible with GeoAnalytics Engine, check out the sample notebooks, tutorials, and blog posts.