Geosyntec / python-tidegates

🌊 ArcToolbox to analyze flooding due to storm surges and climate change
http://geosyntec.github.io/python-tidegates/
BSD 3-Clause "New" or "Revised" License
2 stars 5 forks source link

utils.raster_to_polygons failing with ExecuteError #47

Open HEdingfield opened 8 years ago

HEdingfield commented 8 years ago

This error currently causes 6 tests to fail:

Traceback:

Analyzing flood elevation: 7.8 ft
---------------------------------
WorkSpace set to H:\Dev\PyCharm Projects\python-tidegates\tidegates\testing\analyze
Loading DEM H:\Dev\PyCharm Projects\python-tidegates\tidegates\testing\analyze\dem.tif
Processing H:\Dev\PyCharm Projects\python-tidegates\tidegates\testing\analyze\zones.shp polygons
Clipping DEM to extent of H:\Dev\PyCharm Projects\python-tidegates\tidegates\testing\analyze\zones.shp
Converting rasters to arrays
Flooding areas up to 7.8 ft
Converting flooded array to a raster dataset
Converting raster of floods to polygons

Error
Traceback (most recent call last):
  File "C:\Python27\ArcGIS10.2\lib\unittest\case.py", line 327, in run
    testMethod()
  File "C:\Python27\ArcGIS10.2\lib\site-packages\nose\case.py", line 197, in runTest
    self.test(*self.arg)
  File "H:\Dev\PyCharm Projects\python-tidegates\tidegates\tests\test_toolbox.py", line 361, in test_analyze_no_optional_input
    buildings=None
  File "H:\Dev\PyCharm Projects\python-tidegates\tidegates\toolbox.py", line 662, in analyze
    asMessage=True
  File "H:\Dev\PyCharm Projects\python-tidegates\tidegates\analysis.py", line 149, in flood_area
    **verbose_options
  File "H:\Dev\PyCharm Projects\python-tidegates\tidegates\utils.py", line 285, in wrapper
    return func(*args, **kwargs)
  File "H:\Dev\PyCharm Projects\python-tidegates\tidegates\utils.py", line 719, in raster_to_polygons
    raster_field="Value",
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\conversion.py", line 241, in RasterToPolygon
    raise e
ExecuteError: ERROR 010157: Unable to open feature class H:\Dev\PyCharm Projects\python-tidegates\tidegates\testing\analyze\_temp_flooding_no_opts7_8.
Failed to execute (RasterToPolygon).
phobson commented 8 years ago

I thought #45 took care of this?

HEdingfield commented 8 years ago

No, this problem still exists and is triggered by 11 tests now that I got Fiona working. In addition to the 6 above:

phobson commented 8 years ago

@HEdingfield can you take a crack at fixing the function? can you get that arcpy function to work outside of the tool?

phobson commented 8 years ago

@HEdingfield try forcing the function to use the spatial extension, i.e.,

@update_status() # layer
def raster_to_polygons(zonal_raster, filename, newfield=None):
    """ ... """
    with OverwriteState(True), Extension("spatial"):
        results = arcpy.conversion.RasterToPolygon(
            in_raster=zonal_raster,
            out_polygon_features=filename,
            simplify="SIMPLIFY",
            raster_field="Value",
        )

    [yada yada]
phobson commented 8 years ago

@HEdingfield

And before you get too far down the rabbit hole, clone in to a fresh, normal directory away from pycharm and try the tests:

cd C:\users\hedingfield\Desktop
pip uninstall tidegates
git clone git@github.com:Geosyntec/python-tidegates.git
cd python-tidegates
pip install -e .
nosetests