Create a Buffer GP Service with multiple input geometry type (Point, Polygon, Polyline)

571
11
Jump to solution
03-01-2024 07:59 AM
Labels (2)
Bertrand_Laurancin
New Contributor III

Hello,

I try to create from ArcGIS Pro a Buffer GP Service that accepts as input multiple geometry type (Point, Polygon, Polyline).

I tried this script :

 

import arcpy
arcpy.env.overwriteOutput = True
##arcpy.addOutputsToMap = True
if __name__ == "__main__":
    inputFc = arcpy.GetParameterAsText(0)
    outputFc = r"C:\temp\output_buffer.shp"
##    arcpy.AddMessage(inputFc)   
    # Create a Describe object from the feature class
    desc = arcpy.Describe(inputFc)
    # Print Sahpe Type
##    arcpy.AddMessage("Shape Type :   " + desc.shapeType)
    shpType = desc.shapeType
    if(shpType == "Polygon"):
        arcpy.AddMessage("Shape Type :   " + desc.shapeType)
        arcpy.analysis.Buffer(inputFc, outputFc, "500 meters")
    elif(shpType == "Point"):
        arcpy.analysis.Buffer(inputFc, outputFc, "500 meters")
    elif(shpType == "Polyline"):
        arcpy.analysis.Buffer(inputFc, outputFc, "500 meters") 

 

 

It works with ArcGIS Pro :

Bertrand_Laurancin_0-1709307815328.png

Bertrand_Laurancin_2-1709307859280.png

However, when I publish the result of the script (from ArcGIS pro) to a Web Tool (GP Service), the Geometry Type is always the same that the input geomtry used in ArcGIS Pro :

Bertrand_Laurancin_3-1709307988191.png

Therefore, in a WAB application, i can choose only a point feature layer as input :

Bertrand_Laurancin_4-1709308090366.png

 

I think it's not possible because "The geometry type comes from the input and output features that are used to create the result" | Source https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/share-analysis/web-tool-setting...

 

Is it really not possible ?

Is there a workaround ?

Do you have any idea ?

Thank you,

Bertrand

 

0 Kudos
2 Solutions

Accepted Solutions
GeeteshSingh07
Occasional Contributor II

Hi @Bertrand_Laurancin , I believe it is possible.  Could you check these two things before publishing the web tool and verify if that works?

1st- The filter is set in script tool:

GeeteshSingh07_0-1709564744879.png

 

2nd while publishing, "Input Mode" for the tool is "User defined Value".

GeeteshSingh07_1-1709564821182.png

 

View solution in original post

0 Kudos
Bertrand_Laurancin
New Contributor III

Hi @GeeteshSingh07,

You are right.

I created a model builder :

Bertrand_Laurancin_0-1709634757354.pngBertrand_Laurancin_1-1709634796590.png

It works in MapViewer :

Bertrand_Laurancin_2-1709634992999.png

However, in WAB it still not able to run against a different geometry type compared to the original geometry used to create the tool in ArcGIS Pro :

Bertrand_Laurancin_3-1709635096074.png

 

I found about a bug :

BUG-000161045 : When adding a geoprocessing service as a widget to ArcGIS Web AppBuilder, the tool does not honor the same geometry types as the geoprocessing tool

Thank you for your help,
Bertrand

View solution in original post

11 Replies
Bertrand_Laurancin
New Contributor III

Thank you @GeeteshSingh07.
I think it is not possible and as designed:
"The geometry type comes from the input and output features that are used to create the result. It cannot be modified on the Content tab. You need to rerun the tool using features of the specified geometry type, and share the result created by the run" | Source : https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/share-analysis/web-tool-setting...

GeeteshSingh07
Occasional Contributor II

Hi @Bertrand_Laurancin , I believe it is possible.  Could you check these two things before publishing the web tool and verify if that works?

1st- The filter is set in script tool:

GeeteshSingh07_0-1709564744879.png

 

2nd while publishing, "Input Mode" for the tool is "User defined Value".

GeeteshSingh07_1-1709564821182.png

 

0 Kudos
Bertrand_Laurancin
New Contributor III

Hi @GeeteshSingh07,

I tried it :

import arcpy
arcpy.env.overwriteOutput = True
arcpy.addOutputsToMap = True
fcs_types = arcpy.GetParameterAsText(0)
fcs_list = fcs_types.split(";")
outputFcPt = r"C:\temp\output_buffer_pt.shp"
outputFcLine = r"C:\temp\output_buffer_polyline.shp"
outputFcPolygon = r"C:\temp\output_buffer_polygon.shp"
if __name__ == "__main__":
    for fc_type in fcs_list:
        arcpy.AddMessage("Processing: {}".format(fc_type))
        desc = arcpy.Describe(fc_type)
        shpType = desc.shapeType
        if(shpType == "Polygon"):
            arcpy.AddMessage("Shape Type :   " + desc.shapeType)
            arcpy.analysis.Buffer(fc_type, outputFcPolygon, "500 meters")
        elif(shpType == "Point"):
            arcpy.AddMessage("Shape Type :   " + desc.shapeType)
            arcpy.analysis.Buffer(fc_type, outputFcPt, "500 meters")
        elif(shpType == "Polyline"):
            arcpy.AddMessage("Shape Type :   " + desc.shapeType)
            arcpy.analysis.Buffer(fc_type, outputFcLine, "500 meters")    

 

Bertrand_Laurancin_0-1709565201799.png

Bertrand_Laurancin_1-1709565251051.png

In the REST Description it is OK :

Bertrand_Laurancin_2-1709565355732.png

But in my WAB App i can select only a point layer as input (the same geometry type as the gp result used in ArcGIS Pro to publish the gp service) whereas the WebMap contains polygon and polyline layers :

Bertrand_Laurancin_4-1709565598254.png

 

 

0 Kudos
GeeteshSingh07
Occasional Contributor II

What if we open the web tool in ArcGIS Pro?

Open from Catalog Pane > Portal > Open the tool (web)

@Bertrand_Laurancin 

If web tool here allows all point, line, polygons, then, could you try reconfigured the widget in web app?

0 Kudos
Bertrand_Laurancin
New Contributor III

@GeeteshSingh07,

Yes in ArcGIS pro i can choose point, polyline or polygon layers from the gp service :

Bertrand_Laurancin_0-1709566680635.png

However, in the WAB i can select only a point layer as input (the same geometry type as the gp result used in ArcGIS Pro to publish the gp service) whereas the WebMap contains polygon and polyline layers :

Bertrand_Laurancin_1-1709566774717.pngBertrand_Laurancin_2-1709566800826.png

 

 

0 Kudos
GeeteshSingh07
Occasional Contributor II

 @Bertrand_Laurancin, unfortunately I don't have web appBuilder for testing it. However, in my Portal web map as well, it shows me all point, lines, polygon layers. 

Maybe you test with new web appbuilder or experience builder, as this isn't expected behavior...if it still occurs there, we might have discovered a bug

0 Kudos
Bertrand_Laurancin
New Contributor III

Hi @GeeteshSingh07 ,

Thank you for your tests.

I don't understand how you can use the gp service in a WebMap (with portal viewer ?)

Have a good day.

0 Kudos
GeeteshSingh07
Occasional Contributor II

@Bertrand_Laurancin on the item detail's page of your web tool, we have option "Open in Map Viewer Classic".

GeeteshSingh07_0-1709628096313.png

 

0 Kudos