2

Is it possible to create and edit mosaic datasets via web tools / geoprocessing services?

I managed to publish and run a script tool performing an intersect with two shape files.

import arcpy
a = arcpy.GetParameterAsText(0)
b = arcpy.GetParameterAsText(1)

arcpy.analysis.Intersect([a, b], f"{arcpy.env.scratchGDB}\intersected", "ALL") arcpy.SetParameter(2, f"{arcpy.env.scratchGDB}\intersected")

When I try it with the project home GDB path in the registered folder instead of the scratchGDB, I get an empty feature class and map layer. The two input parameters of the script tool are of type shapefile. I kept "add optional output feature service parameter" checked for the derived output parameter whilst publishing, so the output lands in a feature service and the map.

enter image description here

When I try to do something similar for creating a mosaic dataset, I get either broken project datasource or no error and no output. For example when writing the MD to the scratch GDB:

ERROR 000732: Mosaic Dataset: Dataset C:\Users\HACKEN~1\AppData\Local\Temp\37\ArcGISProTemp74484\scratch.gdb\S_col does not exist or is not supported
Failed to execute (MakeMosaicLayer).

I have tried it with the Model Builder, scripts and MDCS. I have tried using an existing Mosaic Layer. arcpy.management.MakeMosaicLayer() does not recognize the Mosaic dataset in the input. Do I have to work with image services on the image server for intermediate results?

import arcpy
arcpy.CreateMosaicDataset_management(arcpy.env.scratchGDB, "mosaic_dataset","25832", "1","8_BIT_UNSIGNED", "NONE")
#arcpy.management.MakeMosaicLayer(f"{arcpy.env.scratchGDB}\\S_col", "md_lyr")
arcpy.management.AddRastersToMosaicDataset(f"{arcpy.env.scratchGDB}\\mosaic_dataset", "Raster Dataset",
                                           r"D:\FileShare_AGE\2022-11-24", "#", "#",
                                           "#", "2", "#", "#", "#", "*col.tif", "SUBFOLDERS", "EXCLUDE_DUPLICATES")
arcpy.SetParameter(0, f"{arcpy.env.scratchGDB}\\S_col")

enter image description here

I have tried with datatypes mosaic layer, mosaic dataset, image service and feature class for the output parameter, as well as home gdb instead of scratch gdb.

  • Wait. You're using the scratch geodatabase that gets created anew for each service to store the mosaic dataset? Do you see why that can't possibly work? You need a permanent registered location that doesn't get deleted 5 minutes after the previous run to store the dataset. – Vince May 29 '23 at 11:27
  • unfortunately, it does not work with the mosaic dataset in a normal geodatabase either. – MoritzMoreira May 30 '23 at 07:10
  • Then [Edit] the Question to document your process with a valid mosaic dataset. And add an ArcPy.AddMessage with the parameter value to the script and report the output. – Vince May 30 '23 at 11:35
  • Why do you want to make a Mosaic Dataset using a GP Service. What is your USER workflow that requires this? – KHibma Jun 01 '23 at 14:03
  • This is actually just a test. In the end, we want to run a script with GP commands that calls MDCS several times. When I ran that, I got "broken data source \Footprints" So I tried to narrow it down to createMosaicDataset(), without success so far. – MoritzMoreira Jun 01 '23 at 14:24
  • I don't know anything about the MDCS tool. I will say that the Create Mosaic Dataset tool could be difficult to use as GP Service. Any tool that takes a path parameter as an input requires special consideration. Not always, but more often than not if you're using a tool that wants a path parameter, you probably should re-evaluate your workflow. I know you said this is a test, but it's a "hard test" to get right. – KHibma Jun 01 '23 at 14:32
  • I see. Well, my organization would like to have it as a web tool, to be sure everyone executes the same thing and central administration. And it is also part of my bachelor thesis...If it can't be done, than that is the result, but the reason why I still keep thinking that it might work is this video. https://mediaspace.esri.com/meia/t/1_q98qok22 At 23:14 , your collegue says it's so easy, "run it as a GP service". We aksed the support here in Germany for the sript half shown in the video, but they did not have it. – MoritzMoreira Jun 01 '23 at 14:41
  • It can be done. The create mosaic dataset tool is providing, lets call, a container for your raster to go in, right? Instead of using that tool, would it make more sense to have an empty mosaic dataset that is just copied where users would push their rasters into. (I assume you want a new, clean mosaic for each tool run). Copying a "template" one would be faster than creating a new one each time. – KHibma Jun 01 '23 at 14:47
  • I did try creating a Mosaic Dataset and a mosaic layer from it manually and then use it in the code with md = "layerName". That way I ca publish, but it does not find the layer when I run the web tool. – MoritzMoreira Jun 03 '23 at 09:15

0 Answers0