Select to view content in your preferred language

Create RestEndPoint Geoprocessing Tool

708
4
Jump to solution
01-06-2023 10:37 AM
kapalczynski
Occasional Contributor III

I am trying to create a GP Tool that I am trying to publish to Portal.  It works in ArcGIS Pro but will not publish... 

  1. I created a new Toolbox
  2. I created a New Script in the tool box
  3. I set 4 parameters in the Script and set defaults for them
    • Parameters                                        Default Values
    • in_las                                                  C:\Temp\LazToLas\LazFiles
    • target_folder                                       C:\Temp\LazToLas\LazFiles
    • define_coordinate_system              ALL_FILES
    • in_coordinate_system                     GEOGCS["GCS_NAD_1983_2011, DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]

I put this code in the Script and when I double click the script in the toolbox it runs fine….Basically converting .laz files to .las files.

I then go to publish this GP Tool to my server and I get these two errors:

  • Server version 10.8.1 tool ConvertLas_conversion does not have new parameter in_coordinate_system
  • Server version 10.8.1 tool ConvertLas_conversion does not have new parameter define_coordinate_system

Why does this run via double clicking the script in the toolbox and fails when I try to publish this?  Errors above…..

 

------- Parameters on the Script File in the Toolbox

kapalczynski_1-1673030156342.png

------- ERROR:

 

kapalczynski_0-1673029821531.png

------- CODE:

import arcpy
def ScriptTool(param0, param1, param2, param3):
    
    # Script execution code goes here
    LazFiles = param0
    LasDataset = param1
    defineCoord = param2
    inCoord = param3
    OutputLASDataset_lasd = param1 + "output.lasd"
    
    arcpy.conversion.ConvertLas(in_las=LazFiles, target_folder=LasDataset, file_version="SAME_AS_INPUT", point_format="",compression="NO_COMPRESSION",
                                las_options=["REARRANGE_POINTS"], out_las_dataset=OutputLASDataset_lasd,define_coordinate_system=param2, in_coordinate_system=param3)

    
    return
# This is used to execute code if the file was run but not imported
if __name__ == '__main__':
    # Tool parameter accessed with GetParameter or GetParameterAsText
    param0 = arcpy.GetParameterAsText(0)
    param1 = arcpy.GetParameterAsText(1)
    param2 = arcpy.GetParameterAsText(2)
    param3 = arcpy.GetParameterAsText(3)
"GEOGCS['GCS_NAD_1983_2011',DATUM['D_NAD_1983_2011',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]"
    ScriptTool(param0, param1, param2, param3)

 

0 Kudos
1 Solution

Accepted Solutions
sxw_eaglegis
Esri Contributor

Yeah it looks like the spatial reference parameters were added to the convert LAS tool at ArcGIS Server 10.9.

I believe you'll need to publish from ArcGIS Pro 2.7 or lower (ideally 2.7 or 2.6) to get that to work.

View solution in original post

0 Kudos
4 Replies
sxw_eaglegis
Esri Contributor

Hi there,

It might be the version of ArcGIS Server you've got (10.8.1) does not have those two parameters available yet, they may have been added at a later version.

What version of ArcGIS Pro are you using?

Take note of this when publishing geoprocessing services - https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/share-analysis/geoprocessing-se...

 

0 Kudos
kapalczynski
Occasional Contributor III
  • So I removed those two parameters from the tool properties
  • I removed them from my python code 
  • I am still getting the error?

 

I am using ArcGISPro 2.9.5

We are on ArcGIS Server 10.8.1

Is this issue related to the version of Pro and Server?  One is expecting the 2 extra parameters and the other is expecting neither?

I thought by removing them from the script it would work but still getting the errors....

 

kapalczynski_0-1673268724457.png

 

import arcpy
def ScriptTool(param0, param1):
    print(param0)
    print(param1)
    LazFiles = param0
    LasDataset = param1
    OutputLASDataset_lasd = param1 + "output.lasd"
    
    arcpy.conversion.ConvertLas(in_las=LazFiles, target_folder=LasDataset, file_version="SAME_AS_INPUT", point_format="",compression="NO_COMPRESSION",
                                las_options=["REARRANGE_POINTS"], out_las_dataset=OutputLASDataset_lasd)   
    return

# This is used to execute code if the file was run but not imported
if __name__ == '__main__':
    # Tool parameter accessed with GetParameter or GetParameterAsText
    param0 = arcpy.GetParameterAsText(0)
    param1 = arcpy.GetParameterAsText(1)

    ScriptTool(param0, param1)

 

 

kapalczynski_2-1673268919941.png

 

 

 

 

 

0 Kudos
sxw_eaglegis
Esri Contributor

Yeah it looks like the spatial reference parameters were added to the convert LAS tool at ArcGIS Server 10.9.

I believe you'll need to publish from ArcGIS Pro 2.7 or lower (ideally 2.7 or 2.6) to get that to work.

0 Kudos
kapalczynski
Occasional Contributor III

@sxw_eaglegis - Ok cool... well thats good news in a way that the code seems to be correct... I will give this a shot....Cheers

0 Kudos