1

I'm attempting to workaround the apparent zonal statistics bug in ArcGIS 10.4 by using rasterstats.zonal_stats.

stats = zonal_stats(shapefile_full_path, rast_full_path,0,1,None,None,{'mean','min','max'},False,False,None,None,False,None,True )

In a standalone script, it works perfectly.

But when called from an ArcPy geoprocessing script by ArcGIS Server, I receive this error:

  File "C:\Python27\ArcGISx6410.4\lib\site-packages\rasterstats\main.py", line 28, in zonal_stats
    return list(gen_zonal_stats(*args, **kwargs))
  File "C:\Python27\ArcGISx6410.4\lib\site-packages\rasterstats\main.py", line 139, in gen_zonal_stats
    with Raster(raster, affine, nodata, band_num) as rast:
  File "C:\Python27\ArcGISx6410.4\lib\site-packages\rasterstats\io.py", line 237, in __init__
    self.src = rasterio.open(raster, 'r')
  File "C:\Python27\ArcGISx6410.4\lib\site-packages\rasterio\__init__.py", line 201, in open
    s.start()
  File "rasterio/_base.pyx", line 67, in rasterio._base.DatasetReader.start (rasterio/_base.c:2557)
  File "C:\Python27\ArcGISx6410.4\lib\site-packages\rasterio\vfs.py", line 30, in parse_path
    parts = urlparse(path)
TypeError: 'NoneType' object is not callable

It is a similar error to this question, but the answer doesn't apply (no RDBMS involved in my script):
ArcGIS Geoprocessing "None Type" Second time

There's no error in the from rasterstats import zonal_stats statement, and the error is raised in rasterio.

Based on this, it appears that this was successful at one point: https://github.com/perrygeo/python-rasterstats/blob/master/docs/notebooks/ArcPy%20and%20rasterstats%20integration.ipynb

Any idea of how to resolve? Can it be resolved?

This is an ArcGIS 10.4.1 Server, but the python.executable is ArcSOC.exe (I suspect this has something to do with it):

Python executable:C:\Program Files\ArcGIS\Server\bin\ArcSOC.exe
Python version:2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)]
Python hexversion:2070af0
os.__file__:C:\Python27\ArcGISx6410.4\Lib\os.pyc
  • updated the question--the snippet is a one-liner (zonal_stats function). – Jay Cummins Sep 23 '16 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.