Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate response Demo crashes #44

Closed
trotor opened this issue Jul 5, 2017 · 23 comments
Closed

Calculate response Demo crashes #44

trotor opened this issue Jul 5, 2017 · 23 comments

Comments

@trotor
Copy link
Collaborator

trotor commented Jul 5, 2017

Steps:

  1. Download ArcSDM and ArcSDM_DemoData.

  2. Unzip ArcSDM-Master.zip, this creates ArcSDM-master folder.

  3. Unzip ArcSDM_DemoData.zip inside ArcSDM-master folder, this creates Data folder.

  4. Execute file InitWorkDir.bat inside ArcSDM-master, this creates work folder.

  5. Open ArcMAP 10.5 and open ArcSDM_Desktop_work.mxd inside work folder

  6. Create folder connection for ArcSDM-master folder.

  7. In Arc Toolbox, select add toolbox and select ArcSDM-master/Toolbox/ ArcSDM.pyt

  8. In CalculateResponse demo.tbx, Step 1 and Step 2 appear with a red x. As well as LogisticRegressionDemotbx

  9. In Step 1, select edit and appears the model where calculate weights appears with a red x.

  10. Selected Calculate weights directly with
    a. Evidence raster layer : lithoname200k, rc_dnsstru, rc_magn_res4k, rc_till_cu, rc_em_real
    b. Training points orogenic gold thin
    c. Changed Output to end in WD
    d. Everting else as default

  11. Run calculate response with the obtained tables, orogenic_gold_thin and defaults

  12. ArcMAP closes. Output obtained before crash:

Running script CalculateResponse...
Reloaded ArcSDM modules
========== arcsdm values  ==========
ArcSdm 5.00.12 for ArcGis (Pro and Desktop)
Workspace:           C:\Users\irca\Downloads\ArcSDM-master\work\database.gdb (LocalDatabase)
Scratch workspace:   C:\Users\irca\Downloads\ArcSDM-master\work\scratch.gdb (LocalDatabase)
Mask:                "study_area" and it is FeatureClass
Mask size:           98856.95500162625
Cell Size:           500.0
# Training Sites:    40
Unit Cell Area:      1.0km^2, Cells in area: 98856.95500162625
Prior Probability:   0.000405
Training Set:        C:\Users\irca\Downloads\ArcSDM-master\work\database.gdb\Study\orogenic_gold_thin
Study Area Raster:   C:\Users\irca\Downloads\ArcSDM-master\work\database.gdb\study_area
Study Area Area:     98856.95500162625km^2
Map Units:           meter
========================================= Starting calculate response =========================================
Study Area:          98856.95500162625
# training points:   40
Prior_prob:          0.00040462504635452285
Input rasters: ['lithoname200k', "'Reclassified rasters\\rc_dnsstru'", "'Reclassified rasters\\rc_em_real'", "'Reclassified rasters\\rc_magn_res4k'", "'Reclassified rasters\\rc_till_cu'"]
Input rasters: ['lithoname200k', 'rc_dnsstru', 'rc_em_real', 'rc_magn_res4k', 'rc_till_cu']
Creating weight rasters
=========================================
Processing lithoname200k
 


@trotor trotor added the bug label Jul 5, 2017
@trotor trotor added this to the Toolbox demo milestone Jul 5, 2017
@trotor trotor self-assigned this Jul 5, 2017
@trotor
Copy link
Collaborator Author

trotor commented Jul 6, 2017

Could someone test this with new demo dataset?

T

@trotor
Copy link
Collaborator Author

trotor commented Jul 11, 2017

Waiting for feedback, can't replicate

@trotor
Copy link
Collaborator Author

trotor commented Jul 19, 2017

Can't replicate this with user description of the problem with new demodata and toolbox (10.4.1 arcgis).

Completed script CalculateResponse...   Succeeded at Wed Jul 19 10:07:13 2017 (Elapsed Time: 1 minutes 17 seconds) | Completed script CalculateResponse...   Succeeded at Wed Jul 19 10:07:13 2017 (Elapsed Time: 1 minutes 17 seconds) | Completed script CalculateResponse... |   | Succeeded at Wed Jul 19 10:07:13 2017 (Elapsed Time: 1 minutes 17 seconds)
-- | -- | -- | -- | --
Completed script CalculateResponse...   Succeeded at Wed Jul 19 10:07:13 2017 (Elapsed Time: 1 minutes 17 seconds) | Completed script CalculateResponse... |   | Succeeded at Wed Jul 19 10:07:13 2017 (Elapsed Time: 1 minutes 17 seconds)
Completed script CalculateResponse...
  | Succeeded at Wed Jul 19 10:07:13 2017 (Elapsed Time: 1 minutes 17 seconds)

@trotor
Copy link
Collaborator Author

trotor commented Jul 19, 2017

Confirmed crash in ArcGis pro 2.0 investigating

@trotor
Copy link
Collaborator Author

trotor commented Jul 19, 2017

arcpy.ArcSDM.CalculateResponse("lithoname200k", r"C:\ArcSDM\work\database.gdb\lithoname200k_WC", "orogenic_gold_thin", None, -99, 1, r"C:\ArcSDM\work\database.gdb\W_pprb", r"C:\ArcSDM\work\database.gdb\W_std", r"C:\ArcSDM\work\database.gdb\W_MDvar", r"C:\ArcSDM\work\database.gdb\W_Tstd", r"C:\ArcSDM\work\database.gdb\W_conf")

This crashes the tool - investigating

@trotor
Copy link
Collaborator Author

trotor commented Jul 19, 2017

Command line :

arcpy.ImportToolbox(r"C:\arcsdm\toolbox\arcsdm.pyt")

arcpy.env.workspace = r"C:\ArcSDM\work\database.gdb"
arcpy.env.scratchWorkspace = r"C:\ArcSDM\work\database.gdb"
arcpy.env.mask = r"C:\ArcSDM\work\database.gdb\study_area"

arcpy.ArcSDM.CalculateResponse(r"C:\ArcSDM\work\database.gdb\lithoname200k", r"C:\ArcSDM\work\database.gdb\lithoname200k_WC", r"C:\ArcSDM\work\database.gdb\orogenic_gold_thin", None, -99, 1, r"C:\ArcSDM\work\database.gdb\W_pprb", r"C:\ArcSDM\work\database.gdb\W_std", r"C:\ArcSDM\work\database.gdb\W_MDvar", r"C:\ArcSDM\work\database.gdb\W_Tstd", r"C:\ArcSDM\work\database.gdb\W_conf")

@trotor
Copy link
Collaborator Author

trotor commented Jul 19, 2017

Crash happens on this line (186):
gp.AddJoin_management(RasterLayer,"Value",Wts_Table,"CLASS")

@irvcaza
Copy link
Collaborator

irvcaza commented Jul 19, 2017

Managed to execute Calculate response successfully using only

  • rc_till_cu
  • rc_magn_res4k
  • rc_em_real
    But any combination that contains
  • rc_dnsstru or
  • lithoname_200k
    produces the error. Therefore is more related to the layers.

Studding deeper I found out that the Coordinate Systems differ

  • orogenic_gold_thin -> EUREF_FIN_TM35FIN
  • rc_dnsstru -> ETRS_1989_Transverse_Mercator
  • rc_em_real -> EUREF_FIN_TM35FIN
  • rc_till_cu -> EUREF_FIN_TM35FIN
  • rc_magn_res4k -> EUREF_FIN_TM35FIN
  • lithoname200k -> ETRS_1989_Transverse_Mercator

That is possibly the origin of our error

@trotor
Copy link
Collaborator Author

trotor commented Jul 20, 2017

It is problem with output spatial reference - needs confirmation

@trotor
Copy link
Collaborator Author

trotor commented Jul 21, 2017

https://www.dropbox.com/s/nxmzxex0jhpbskq/issue44.rar?dl=0

Waiting for confirmation of bug.

@trotor trotor removed the Demo label Jul 21, 2017
@irvcaza
Copy link
Collaborator

irvcaza commented Jul 21, 2017

Issue sent to Esri DE, waiting for response.

@trotor
Copy link
Collaborator Author

trotor commented Oct 8, 2017

Closing this - demodata fixed and problem pinpointed. Thanks!

@trotor
Copy link
Collaborator Author

trotor commented May 21, 2018

Reopening this because of #98

@trotor trotor reopened this May 21, 2018
@Eliasmgprado
Copy link

Eliasmgprado commented Jul 10, 2018

I'm with the same problem, using the data in ArcSDM_Demodata/DemoData_version_files (dowloaded from github) using the following layers for Wofe Demo testing:

  • orogenic_Au
  • lithoname200k
  • rc_till_cu
  • rc_till_co
  • rc_dst_worms
  • rc_appa_res
  • rc_magn_res4k

ArcMap crashes when Calculate Response is executed. I have already checked the spatial reference and its ok.

Running on ArcMap 10.5.1

@trotor
Copy link
Collaborator Author

trotor commented Jul 10, 2018 via email

@Eliasmgprado
Copy link

Running on ArcMap 10.5.1

@Eliasmgprado
Copy link

I got it!

The problem is in line 211 of calculateresponse.py

arcpy.AddJoin_management(RasterLayer,"VALUE",Wts_Table,"CLASS")

When i run the code below

my_raster_layer = arcpy.Raster(RasterLayer)
if my_raster_layer.hasRAT:
     arcpy.AddMessage("Has a VAT!")
else:
     arcpy.AddMessage("No VAT!")

before the line 205 - arcpy.MakeRasterLayer_management(Input_Raster,RasterLayer) -
the algorithm output "No VAT", that is, the RasterLayer created do not have Attribute Table, probably this is causing the crash.

This way, i have make the following modifications to the calculateresponse.py code for circunvent this issue.

  • Comment line 205
    arcpy.MakeRasterLayer_management(Input_Raster,RasterLayer)
  • Modified line 211, replacing RasterLayer by Input_Raster
    arcpy.AddJoin_management(Input_Raster,"VALUE",Wts_Table,"CLASS")
  • Modified line 236, replacing RasterLayer by Input_Raster
    arcpy.CopyRaster_management(Input_Raster,Temp_Raster,'#','#',NoDataArg2)
  • Comment line 381
    gp.makerasterlayer(Input_Raster,RasterLayer)
  • Comment line 383, No need for AddJoin again, as the Input_Raster already has the join
    gp.AddJoin_management(Input_Raster,"Value",Wts_Table,"CLASS")
  • Modified line 397, replacing RasterLayer by Input_Raster
    arcpy.CopyRaster_management(Input_Raster, Temp_Raster,"#","#",NoDataArg2)

After these modifications the code is running well. However for AddJoin_management() function work with the Input_Raster, i have to export all the used rasters to a gdb before running the tool.

Thanks for the attention, and for the help.

@trotor
Copy link
Collaborator Author

trotor commented Jul 11, 2018 via email

@Eliasmgprado
Copy link

Yes, for AddJoin_management to work without use the makerasterlayer function, the input must be with geodatabase. But if you want the tool to accept file system inputs, you can add some lines of code to transform the input files to geodatabase before start join the tables.

@trotor
Copy link
Collaborator Author

trotor commented Jul 12, 2018 via email

@artolaiho
Copy link
Collaborator

I haven't same test data than above but I have tested with current data. My experience is that Calculate Response (from arto-dev branch) works with ArcMap and ArcGIS Pro if workspace is either File Geodatabase (which I recommend) or File System.

Here is short test using python on ArcMap 10.6.1:

import arcpy
print (arcpy.env.mask)
C:\ArcSDM\Work\DemoData_version_files\derivatives\study_area_g\study_area_g
import arcgisscripting
gp = arcgisscripting.create()
print(gp.workspace)
C:\ArcSDM\work
print(gp.scratchworkspace)
C:\ArcSDM\work\Scratch
Input_Raster = r"C:\ArcSDM\Work\DemoData_version_files\geology\lithoname200k\lithoname200k"
!!! Calculate Response may crash if Input Raster is RasterDataset but don't crash if it is RasterBand
Wts_Table = r"C:\ArcSDM\Work\DemoData_version_files\lithoname200k_CT.dbf"
!!! This table is output from Calculate Weights.
Training_Points = r"C:\ArcSDM\Work\DemoData_version_files\shape_files\Orogenic_Au.shp"
outputrastername = Input_Raster.replace(".","_")
outputrastername = outputrastername[:10] + "W"
Output_Raster = gp.CreateScratchName(outputrastername, '', 'rst', gp.scratchworkspace)
RasterLayer = "OutRas_lyr"
arcpy.MakeRasterLayer_management(Input_Raster,RasterLayer)
<Result 'OutRas_lyr'>
!!! MakeRasterLayer writes RasterLayer to TEMP folder.
arcpy.AddJoin_management(RasterLayer,"VALUE",Wts_Table,"CLASS")
<Result 'OutRas_lyr'>
Temp_Raster = gp.CreateScratchName('tmp_rst', '', 'rst', gp.scratchworkspace)
arcpy.CopyRaster_management(RasterLayer,Temp_Raster,'#','#','#')
<Result 'C:\ArcSDM\work\Scratch\tmp_rst17'>
outras = arcpy.sa.Lookup(Temp_Raster,"WEIGHT")

and so on... (without crash)

@artolaiho
Copy link
Collaborator

This works also with ArcMap 10.6.1 and ArcGIS Pro 2.5:
import arcpy
arcpy.ImportToolbox(r"C:\ArcSDM\Toolbox\ArcSDM.pyt")
arcpy.env.workspace = r"C:\ArcSDM\Work"
arcpy.env.scratchWorkspace = r"C:\ArcSDM\Work\Scratch"
arcpy.env.mask = r"C:\ArcSDM\Work\DemoData_version_files\derivatives\study_area_g\study_area_g"
!!! Note: Mask must be RasterBand, not RasterDataset (study_area_g twice above)
!!! Also Input raster must be RasterBand, not RasterDataset (lithoname200k twice below)
arcpy.ArcSDM.CalculateResponse(r"C:\ArcSDM\work\DemoData_version_files\geology\lithoname200k\lithoname200k", r"C:\ArcSDM\Work\DemoData_version_files\lithoname200k_CT.dbf", r"C:\ArcSDM\work\DemoData_version_files\shape_files\Orogenic_Au.shp", "#", -99, 1, r"C:\ArcSDM\work\W_pprb", r"C:\ArcSDM\work\W_std", r"C:\ArcSDM\work\W_MDvar", r"C:\ArcSDM\work\W_Tstd", r"C:\ArcSDM\work\W_conf")

@artolaiho
Copy link
Collaborator

Load the newest version of ArcSDM (V5.02) and test again. If the problem persists, reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants