perrygeo / python-rasterstats

Summary statistics of geospatial raster datasets based on vector geometries.
BSD 3-Clause "New" or "Revised" License
529 stars 117 forks source link

Exit code -1073741819 (0xC0000005) #142

Closed Neavrys closed 7 years ago

Neavrys commented 7 years ago

Hi all, In django console, a simple code as :

from rasterstats import zonal_stats, point_query
stats = zonal_stats('Good Raster/wetlands.json', 'Good Raster/tempRaster.tif')

I received : Process finished with exit code -1073741819 (0xC0000005) (Python Crash)

Here is the files, (geojson and raster): https://www.dropbox.com/sh/gacm4iu00aama4v/AADUm0RD0LYD_0fUV6Mxo3QFa?dl=0

Version : Windows 10 pro 64 bit PyCharm 2016.3.2 Python 2.7.12 Django 1.10.4 gdal 2.1.3 numpy 1.12.0+mkl rasterio 0.36.0 rasterstats 0.12

Update: The entire Zonal Statistics project, with OGR, OSR, Gdal, numpy, geojson that I code myself, work good but too dam slow. I need a efficient Zonal Statistic with geojson and a raster. This lib could save me but a critical error occurred when I use it without any other code or import.

Work in a virtual environment created by Pycharm. All in 32 bit

Update2 error django console

When ran into Shell from terminal, I got some error details.

FATAL: CPLMalloc(): Out of memory allocating 516 bytes. Python crash

error shell terminal

Alex

sgoodm commented 7 years ago

ran a quick test on ubuntu 14.04 64 bit and it works fine

the json from dropbox is wrapped in quotes, make sure to remove them before trying to run

Neavrys commented 7 years ago

@sgoodm json from dropbox corrected. Even with removing wrapped in quotes. It's still bug.

perrygeo commented 7 years ago

I can't reproduce this either, on OSX or linux.

Can you step through this in a debugger to identify the place it fails?

Neavrys commented 7 years ago

@perrygeo Can't pass main.py at line 28

1.step into: can't pass main.py at line 142

2.step into: can't pass io.py at line 241

3.step into: can't pass rasterioinit.py at line 201

4.step into: Pass thought def parse_path() in vfs.py

5.Return to : rasterioinit.py at line 201 can't pass rasterioinit.py at line 201

6.step into: Pass thought def vsi_path() in vfs.py

7.Return to : rasterioinit.py at line 201 can't pass rasterioinit.py at line 201

8.step into: Pass thought def getLogger() in logging__init__.py

9.Return to : rasterioinit.py at line 201 can't pass rasterioinit.py at line 201

10.step into: Pass thought def log() in logging__init__.py

11.Return to : rasterioinit.py at line 201 can't pass rasterioinit.py at line 201 Crash when step into...

Is't it a library conflict?

perrygeo commented 7 years ago

@Neavrys thanks for diving into the details! Looks like you narrowed down the crash to a Rasterio call., likely some issues with its underlying C libraries. What happens if you try this rasterio code:

import rasterio
with rasterio.open('tempRaster.tif') as src:
    src.read()
Neavrys commented 7 years ago

@perrygeo

With the code you mention, I received in the geodjango console: Process finished with exit code -1073741819 (0xC0000005)

The Shell from terminal won't give error details, just python crash.

With debug: can't pass rasterioinit.py at line 201, just like # 3. in my previous post.

Neavrys commented 7 years ago

Is it my problem ? I think so... [Rasterio-issues-219] (https://github.com/mapbox/rasterio/issues/219)

perrygeo commented 7 years ago

It appears to be a problem with your Rasterio installation. I don't know much about installing rasterio and GDAL on 32-bit windows so I personally can't help with details. I'd encourage you to open a new ticket in the Rasterio repo so we can get more eyes on the issue.

Another option is Anaconda. I usually suggest installing rasterstats via conda-forge. It's not always an option but conda has the only complete solution to the dll problems.