PSU-CSAR / vb-bagis

Source code for BAGIS V3 ESRI Add-In
0 stars 1 forks source link

BASIN Tool - Clipping DEM - smooth DEM bug #34

Closed jdduh closed 5 years ago

jdduh commented 7 years ago

image

When this option is selected, the output BASIN fails to be created.

  1. On ArcGIS 10.2, the users get this error message. image

  2. On ArcGIS 10.4, the process seems to get into an infinite loop and hangs ArcGIS.

lbross commented 7 years ago

Are you using the DEM from the web services or a file? I just tested twice with a file and did not get the error. I have seen a similar error when the temporary space where ArcMap writes the files gets cluttered. Did you try cleaning out the ArcMap files from C:\Windows\System32? Obviously It happens on > one computer since you tested with different ArcMap versions. Any ideas on how I could replicate? There aren't any files to share :-(

This is the code that smooths the DEM: Public Function Smooth(ByVal pRaster As IGeoDataset2, height As Double, width As Double) As IGeoDataset2 ' Declare Variables Dim pNBOp As INeighborhoodOp = New RasterNeighborhoodOp Dim pSmooth As IGeoDataset2 = Nothing Dim pNB As IRasterNeighborhood = New RasterNeighborhood

    pNB.SetRectangle(width, height, ESRI.ArcGIS.GeoAnalyst.esriGeoAnalysisUnitsEnum.esriUnitsCells)

    Try
        ' Create HydrologyOP and Complete Function
        pSmooth = pNBOp.FocalStatistics(pRaster, ESRI.ArcGIS.GeoAnalyst.esriGeoAnalysisStatisticsEnum.esriGeoAnalysisStatsMean, pNB, True)

    Catch ex As Exception
        MsgBox("Smooth Exception: " & ex.Message)

    Finally
        ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pNB)
        ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pNBOp)
    End Try

    Return pSmooth
End Function
jdduh commented 7 years ago

Same problem for the Create AOI from a shapefile tool. Can you explicitly set the scratch workspace?

image

lbross commented 7 years ago

I can try to set the scratch workspace. What do you want me to set it to? It has to be something that will be accessible from everyone's computer. Alternatively, I can swap out the Geoprocessor for the ArcObjects code which will likely solve the problem. This will be a little slower because I need to save the file to disk in between.

jdduh commented 7 years ago

I think the issue is that when a user doesn't have admin privilege the tool cannot write to the System32 folder. That's the case for both Gus and I. I remember we had similar issues on some other tools and we probably set the scratch workspace to somewhere inside the AOI folder (e.g., analysis.gdb or directly under the AOI root folder).

lbross commented 7 years ago

This is for BASIN, not an AOI so we don't have an AOI folder or an analysis folder. I can set it to the root of the basin folder? It looks like there isn't a property for scratch workspace but there is one for OutWorkspace. I will try that and see if it helps.

jdduh commented 7 years ago

Sounds good. The Create AOI from a shapefile tool bypasses BASIN, but you can set the OutWorkspace to the root of the BASIN/AOI folder.

lbross commented 7 years ago

I have implemented the suggested fix. I cannot test it because I don't have the problem. It looks like it sometimes leaves behind an ras file in the outWorkspace but at least it doesn't fail. Do you want me to post a new build of BAGIS V3? I made the fix on the master branch so it doesn't include the auto pseudo site tool.

jdduh commented 7 years ago

It would be great if you could post the updated version. Did you also fixed the Create AOI from a shapefile tool? I encounter the System32 access error even with the Smooth DEM unchecked on that tool.

lbross commented 7 years ago

I didn't change the release number but posted a new version here. I changed the publish date on the add-in so you can check there to see if you have the new one. The create AOI from shapefile tool shares the smooth subroutine with the Basin tool, so I assumed I fixed both. I did test both and both ran without error on my computer.

If create AOI from shapefile continues to fail, it is likely a similar problem elsewhere with a different operation. If it does continue to fail, I will need to see the error message.

jdduh commented 7 years ago

It's all good.

jdduh commented 6 years ago

The same problem resurfaces on BAGIS 3.2-b1. The source DEM is from our webservice.

lbross commented 6 years ago

I just checked the code and the "fix" that we tried is still there: Setting the outWorkspace. Is the error message the same? Is it still trying to write to the System32 folder? If so, I think the only option is to switch it to the GeoProcessor. I am still trying to replicate.

jdduh commented 6 years ago

Here is a screenshot.

bagis_error
jdduh commented 6 years ago

I think what you can do in July is to improve the stability of BAGIS. There are several "typical" bugs that users would encounter, but difficult to replicate by us. NWCC folks know these bugs and are able to get around them. I can set up a clean computer for you to RDP to and test the addins out.

lbross commented 6 years ago

So it is ignoring the outWorkspace that we tried to set. I found a code sample with a slightly different syntax that I am testing. Agreed that a test system with similar permissions to NWCC would be helpful. Just make me a list of what we need to work on :-)

lbross commented 6 years ago

I just posted a new add-in on GitHub that uses the different syntax to set the outWorkspace. https://github.com/PSU-CSAR/vb-bagis/releases/tag/3.2-b1. If that doesn't work, we will have to switch to Geoprocessor.

There is a SetAsNewDefaultEnvironment() method that I haven't run across until today.

jdduh commented 6 years ago

That seems to be working.

lbross commented 6 years ago

Excellent! It's kind of a big deal when you can't create a Basin. I wonder if we should try setting the outWorkspace whenever a Basin or AOI is selected? According to the (minimal) documentation, if you create and configure a new RasterAnalysis object and call the SetAsNewDefaultEnvironment() method, all subsequent Analysis objects will use the set object properties. I am skeptical but it might be worth a try?

jdduh commented 6 years ago

That might be true! I encountered a "reclassify" error (with similar messages related to C:\Windows\System32) when doing a site scenario analysis. The errors don't show up this time. I will reinstall the previous version to capture the error.

lbross commented 6 years ago

Explicitly set outWorkspace using syntax described above when setting Basin or AOI. Hopefully this will be inherited by the downstream tools. Also fixed bug with createAOIFromShapefile where error messages pop when clipping the prism layers from an Image Service. This is a display issue only but annoying since there are so many layers to clip.

jdduh commented 5 years ago

Gus still got an error when the smooth option is enabled. Here are the error messages that he got. image

Followed by this error message. image

Gus is using 10.5.1. with the latest addin (3.4-b1).

lbross commented 5 years ago

See issue #68. Although the headline is deceiving, this is the issue where we were fixing the smooth.