Hello everyone,
I am curently trying to create a python toolbox (atbx) to compute a profile of mosaic dataset values. The tool takes a mosaic dataset and a line feature as inputs. The output is a json file with pixel values and the distande from the orgin of the line.
Important facts:
Until now, I've been working and testing locally with ArcGIS Pro.
I manage to intersect both the mosaic dataset and the line feature, and return pixel values along the line.
However, when I try to filter the mosaic dataset by selecting a date, it returns incoherent values (I notice that there are only 2 different values in the list, it is strange).
Here is what I do in details to filter : I use "arcpy.management.MakeMosaicLayer" to create a temporary layer, with a "where_clause = f"mydate >= timestamp '{startDate}' AND mydate< timestamp '{endDate}'"" . "mydate" is the date field from the mosaic dataset, formatted this way : "YYYY-MM-DD hh:mm:ss.s".
I suppose that the method "MakeMosaicLayer" creates a new layer without keeping the mosaic dataset paths, which would explain why the values are wrong.
Is there a way to filter such a mosaic dataset by date in this case ?
Solved! Go to Solution.
I found the problem. It came from the python script.
In the script I used a arcpy.management.MakeMosaicLayer with a "with clause" condition to filter the rasters inside the mosaic dataset. And after this I used a arcpy.management.SetMosaicDatasetProperties : this is where it fails when running the script.
I removed this function and instead I set the properties directly inside the arcpy.management.MakeMosaicLayer, this way :
@fcoud92 wrote:Hello everyone,
I am curently trying to create a python toolbox (atbx) to compute a profile of mosaic dataset values. The tool takes a mosaic dataset and a line feature as inputs. The output is a json file with pixel values and the distande from the orgin of the line.
Important facts:
- The mosaic dataset is saved inside a database table (postgre).
- The main objective is to share the tool and use it in Portal.
Until now, I've been working and testing locally with ArcGIS Pro.
I manage to intersect both the mosaic dataset and the line feature, and return pixel values along the line.
However, when I try to filter the mosaic dataset by selecting a date, it returns incoherent values (I notice that there are only 2 different values in the list, it is strange).
Here is what I do in details to filter : I use "arcpy.management.MakeMosaicLayer" to create a temporary layer, with a "where_clause = f"mydate >= timestamp '{startDate}' AND mydate< timestamp '{endDate}'"" . "mydate" is the date field from the mosaic dataset, formatted this way : "YYYY-MM-DD hh:mm:ss.s".
I suppose that the method "MakeMosaicLayer" creates a new layer without keeping the mosaic dataset paths, which would explain why the values are wrong.
Is there a way to filter such a mosaic dataset by date in this case ?
Now it runs correctly.
Instead of trying to export a new mosaic, could you create a featureclass of points at each intersected cell of the mosaic and then use extract to get the values onto the point layer? Then handle however you want your final export to look from there?
Hello, thank you for answering !
The current process is the following : I "try" to filter the mosaic dataset and then I create a point feature : a point is created every x meters on the line. I then intersect the point feature with the "filtered" mosaic. That's how I get the pixel values. If I do not try to filter by date, it works fine.
If I understand your answer well, you mean to directly intersect the line with the mosaic dataset and then convert the intersected pixels into points ? Do I understand you well ? (I am not english native, I am sorry if I seem slow to get it). But in that case, there would still be the problem of intersecting with the correct raster inside the mosaic dataset ?
I found the problem. It came from the python script.
In the script I used a arcpy.management.MakeMosaicLayer with a "with clause" condition to filter the rasters inside the mosaic dataset. And after this I used a arcpy.management.SetMosaicDatasetProperties : this is where it fails when running the script.
I removed this function and instead I set the properties directly inside the arcpy.management.MakeMosaicLayer, this way :
@fcoud92 wrote:Hello everyone,
I am curently trying to create a python toolbox (atbx) to compute a profile of mosaic dataset values. The tool takes a mosaic dataset and a line feature as inputs. The output is a json file with pixel values and the distande from the orgin of the line.
Important facts:
- The mosaic dataset is saved inside a database table (postgre).
- The main objective is to share the tool and use it in Portal.
Until now, I've been working and testing locally with ArcGIS Pro.
I manage to intersect both the mosaic dataset and the line feature, and return pixel values along the line.
However, when I try to filter the mosaic dataset by selecting a date, it returns incoherent values (I notice that there are only 2 different values in the list, it is strange).
Here is what I do in details to filter : I use "arcpy.management.MakeMosaicLayer" to create a temporary layer, with a "where_clause = f"mydate >= timestamp '{startDate}' AND mydate< timestamp '{endDate}'"" . "mydate" is the date field from the mosaic dataset, formatted this way : "YYYY-MM-DD hh:mm:ss.s".
I suppose that the method "MakeMosaicLayer" creates a new layer without keeping the mosaic dataset paths, which would explain why the values are wrong.
Is there a way to filter such a mosaic dataset by date in this case ?
Now it runs correctly.