1

I am trying to calculate the habitat fragmentation of a forested region in Africa in order to protect the areas less fragmented. I have used the tool "Landscape Fragmentation Tool V2 requiring Spatial Analyst" but I have an error during its execution. Could you recommended me another tool to calculate fragmentation of habitats using arcgis 10.1?

The input that I used was a land cover map with 1 and 2 data, and the edge width was 50.

This is the error:

    Executing: Landscape_Fragmentation_Tool Bool_fragm 50 C:\CW2\project_2 fragmentation
Start Time: Mon May 12 22:51:18 2014
Running script Landscape_Fragmentation_Tool...

OUTPUT DATASET NAME IS:

    C:\CW2\project_2\fragmentation.img

DATA EXTRACTED FROM LAND COVER
EDGE FRAGMENTATION IDENTIFIED
INTERIOR, PATCH, AND PERFORATED FRAGMENTATION IDENTIFIED
CATEGORIZING CORE FOREST PATCHES...
  File "C:\arcgis_extras\Landscape_Fragmentation_SA\LFT_SA.py", line 254, in <module>
    gp.RegionGroup_sa("core1_", core_grp, "EIGHT", "WITHIN")

<class 'arcgisscripting.ExecuteError'>: ERROR 010213: Error in reading raster c:\fragdata\core1_.
ERROR 010067: Error in executing grid expression.
Failed to execute (RegionGroup).

Completed script Landscape_Fragmentation_Tool...
Failed to execute (Landscape_Fragmentation_Tool).
Failed at Mon May 12 23:33:04 2014 (Elapsed Time: 41 minutes 46 seconds)

Thanks!

UPDATE:

Here you can find more lines in case you have some idea:

 #-------------------------------------------------------------------
# CLASSIFY CORE FOREST BASED ON PATCH SIZE


gp.workspace = TempWS

gp.AddMessage("CATEGORIZING CORE FOREST PATCHES...")
print "CATEGORIZING CORE FOREST PATCHES..."

gp.Reclassify_sa (fragMap2_f, "Value", "4 1", "core1_", "NODATA")

# region group core class...
core_grp = TempWS + "\\core_grp.img"
gp.RegionGroup_sa("core1_", core_grp, "EIGHT", "WITHIN") <-- The error is here

# convert core groups to txt file...
coreGrpFile = "%s\\coreGrpFile.txt" % TempWS
gp.RasterToASCII_conversion(core_grp, coreGrpFile)

# convert 4 class frag map to txt file...
fragMap_4c = "%s\\fragMap_4c.txt" % TempWS
gp.RasterToASCII_conversion(fragMap2_f, fragMap_4c)


cur = gp.SearchCursor(core_grp)
row = cur.next()

remap_dct = {}
6
  • Can you edit the tool? It sounds like it's just a grid expression which you can pick apart and correct if it's editable. May 12, 2014 at 23:00
  • There were some slight syntax changes between 10 and 10.1. Since the error was thrown for RegionGroup you could check the syntax in the code against 10.1 help and potentially fix it. May 13, 2014 at 1:27
  • 1
    The geoprocessor is 9/9.3 (gp.) I'd say that there's more than that that needs looking at. The old version geoprocessor still works though. The whole thing with rasters is now different. It's no longer command(in,out) it's out=command(in). May 13, 2014 at 2:23
  • I am looking at python to try to modify the script. Thanks.
    – Krahsin
    May 13, 2014 at 22:15
  • So, could that be considered the answer? If you can edit your question with a few lines (around line 254) I can have a look at it and perhaps make a suggestion as an answer to close this question off. May 13, 2014 at 22:30

1 Answer 1

1

The problem seems to be with "core1_", assuming the geoprocessor is 9.3, look for this very close to the top of the file:

import arcgisscripting # may be others on the line but this is the one that's important
gp = arcgisscripting.create(9.3)

I have tested it using the 9.3 geoprocessor, if it just says arcgisscripting.create() there may be differences. The Reclassify_sa wants to create a raster and seems to have no problem with "core1_" as an output but RegionGroup_sa doesn't want to pick it up.

gp.workspace = TempWS

gp.AddMessage("CATEGORIZING CORE FOREST PATCHES...")
print "CATEGORIZING CORE FOREST PATCHES..."

TempCore1 = TempWS + "\\TempCore1" # an ESRI GRID in the temp workspace, name isn't important
gp.Reclassify_sa (fragMap2_f, "Value", "4 1", TempCore1, "NODATA")

# region group core class...
core_grp = TempWS + "\\core_grp.img"
gp.RegionGroup_sa(TempCore1, core_grp, "EIGHT", "WITHIN") <-- The error is here

# I'll put this here but you need to search the rest of the file
# and see if "Core1_" is used again and move this to after the last
# instace of "Core1_"
gp.delete(TempCore1) # clean up the temp raster for the next pass.

# convert core groups to txt file...
coreGrpFile = "%s\\coreGrpFile.txt" % TempWS
gp.RasterToASCII_conversion(core_grp, coreGrpFile)

# convert 4 class frag map to txt file...
fragMap_4c = "%s\\fragMap_4c.txt" % TempWS
gp.RasterToASCII_conversion(fragMap2_f, fragMap_4c)

This may not be the only problem, it is possible it will trip up again at a later stage but we can address that if/when it happens.

1
  • Hi, I'm sorry, I could not answer before. Finally, I have installed Arcgis 9.3 and the script worked perfectly without modification. Thank you very much for your help,
    – Krahsin
    May 27, 2014 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.