Overlay combines two DataFrames into a single DataFrame using one of five overlay types: Intersect, Erase, Union, Identity, or Symmetric Difference.
Overlay requires that two inputs are specified using the
overlay_parameters in the
run()method. The two supported overlay types and input geometries are described in the following tables:
Intersect Erase Union Identity Symmetric Difference Point and point Point and linestring Point and polygon Linestring and point Linestring and linestring Linestring and polygon Polygon and point Polygon and linestring Polygon and polygon Full supportPartial supportNo support
The following table summarizes the overlay operations:
Overlay type Description Intersect The geometries or portions of geometries in the overlay DataFrame that overlap the input DataFrame are returned. This is the default. Erase The geometries or portions of geometries in the input DataFrame that do not overlap the overlay DataFrame are returned. Union The result will contain a geometric union of the input DataFrame and overlay DataFrame. All geometries and attributes will be returned. Identity The result will contain geometries or portions of geometries that overlap in both the input DataFrame and overlay DataFrame. Symmetric Difference The result will contain geometries or portions of geometries of the input DataFrame and the overlay DataFrame that do not overlap.
When applying the indentity, intersect, symmetric difference, or union overlay types, fields from both DataFrames (
overlay_) are in the result. If the inputs have the same field names, the overlay fields will be renamed
fieldname_. For example, if your
input_had the fields
state, and the
overlay_had the field
county, your output DataFrame would have the fields
Sliver results may be excluded based on the tolerance of the processing spatial reference.
The tool outputs records that include the following fields in addition to the
|If your input had a geometry column, a new field named |
|Fields from the ||When you use identity, intersect, symmetric difference or union overlay type.|
Improve the performance of Overlay by doing one or more of the following:
Only analyze the records in your area of interest. You can pick the records of interest by using one of the following SQL functions:
Use the Spatiotemporal join tool if you want to join two DataFrames based on their spatial relationship.
The following functions complete spatial overlay operations:
For more details, go to the GeoAnalytics Engine API reference for overlay.
|Runs the Overlay tool using the provided DataFrames.||Yes|
|Sets the type of overlay to be performed. The default is intersect.||No|
# Log in import geoanalytics geoanalytics.auth(username="myusername", password="mypassword") # Imports from geoanalytics.tools import Overlay from geoanalytics.sql import functions as ST # Paths to development area and planned pathway datasets development_path="https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/" \ "/services/DevelopmentProjectArea/FeatureServer/0" pathway_path="https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/" \ "services/DevA_Pathways/FeatureServer/1" # Create a DataFrame for the development areas and pathways development_df=spark.read.format("feature-service").load(development_path) pathway_df=spark.read.format("feature-service").load(pathway_path) # Use Overlay to union the pathways with the development area. # The result will be a DataFrame containing the development area enhanced with # planned pathway geometries and information overlay_result=Overlay() \ .setOverlayType(overlay_type="Union") \ .run(input_dataframe=development_df, overlay_dataframe=pathway_df) overlay_result.select("OBJECTID", "shapeType", "Z_Min", "Z_Max").show(5)
+--------+----------------+----------------+----------------+ |OBJECTID| shapeType| Z_Min| Z_Max| +--------+----------------+----------------+----------------+ | 1|RoundaboutIsland|37.0454299999983|37.0454299999983| | 1| Street|34.9831799999956|36.6633500000025| | 1| Street|30.7013000000006|37.0741500000004| | 1| Street|41.7830899999972|41.8313999999955| | 1|RoundaboutIsland|41.7074100000027|41.7074100000027| +--------+----------------+----------------+----------------+ only showing top 5 rows
# Plot the resulting development and pathway areas result_plot=overlay_result.st.plot(facecolor="lightblue", edgecolors="navy", figsize=(16,10) ) result_plot.set_title("Development area (Multnomah, Oregon) enhanced with" \ "information for planned pathways") result_plot.set_xlabel("X (Meters)") result_plot.set_ylabel("Y (Meters)")