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

Map(Grid) causes Python to crash on Windows #151

Open
biednick opened this issue Jul 25, 2019 · 2 comments
Open

Map(Grid) causes Python to crash on Windows #151

biednick opened this issue Jul 25, 2019 · 2 comments

Comments

@biednick
Copy link

I've been following the "plot over Google map" tutorial in an attempt to plot some data points over a satellite image. However, the Map function fails every time. My code will run until Map is called, hangs for 30-45 seconds, then I get a pop up window that says "Python has stopped working. A problem has caused the program to stop working correctly. Windows will close the program and notify you if a solution is available." I'm running Python 3.7.3 on Windows 10 64 bit. Based on how easy is is to reproduce the error, where it occurs in the code, and the error itself I believe it is an issues with Salem on Windows/Python 3.7 rather than a flaw in my code.

This is the function I am trying to run:

import matplotlib.pyplot as plt
import pandas as pd
import salem
from salem import get_demo_file, DataLevels, GoogleVisibleMap, Grid, Map
from pyproj import Proj

def showImage():
    g = GoogleVisibleMap(x=[X1, X2], y=[Y1, Y2],    #Censored lat/long since it is where I live
                     scale=2,
                     maptype='satellite')
    
    grid = g.grid
    print(grid)
    salem.Map(grid, factor=1, countries=False)

This example is the simplest version I have been able to reproduce the issue with. g was taken from the example given in salem.Grid documentation:

import salem
from salem import Map, Grid
from pyproj import Proj

g = Grid(nxny=(3, 2), dxdy=(1, 1), x0y0=(0, 0), proj="wgs84")
Map(g)

Here's a list of all my installed packages:

Package         Version
--------------- -----------
altgraph        0.16.1
asn1crypto      0.24.0
attrs           19.1.0
bcrypt          3.1.6
certifi         2019.6.16
cffi            1.12.3
cftime          1.0.3.4
chardet         3.0.4
Click           7.0
click-plugins   1.1.1
cligj           0.5.0
colorama        0.4.1
cryptography    2.7
cycler          0.10.0
decorator       4.4.0
descartes       1.1.0
Fiona           1.8.6
future          0.17.1
GDAL            2.4.1
geopandas       0.5.1
idlex           1.18
idna            2.8
imageio         2.5.0
joblib          0.13.2
kiwisolver      1.1.0
macholib        1.11
matplotlib      3.1.0
motionless      1.3.2
munch           2.3.2
netCDF4         1.5.1.2
networkx        2.3
numpy           1.16.4
osmnx           0.10
pandas          0.24.2
paramiko        2.5.0
pefile          2019.4.18
Pillow          6.1.0
pip             19.1.1
py2exe          0.9.2.2
pyasn1          0.4.5
pycparser       2.19
PyInstaller     3.4
PyNaCl          1.3.0
pyparsing       2.4.0
pyproj          2.2.2
python-dateutil 2.8.0
pytz            2019.1
PyWavelets      1.0.3
pywin32-ctypes  0.2.0
requests        2.22.0
Rtree           0.8.3
salem           0.2.4
scikit-image    0.15.0
scipy           1.3.0
setuptools      41.0.1
Shapely         1.6.4.post2
six             1.12.0
urllib3         1.25.3
xarray          0.12.3
@fmaussion
Copy link
Owner

Thanks for the clear report!

I believe it is an issues with Salem on Windows/Python 3.7 rather than a flaw in my code

Although it's not unlikely that the problem is in Salem, I would rather bet on upstream packages like GDAL or PyProj, which have a long history of not working properly on windows. For example, if I take your code an run it on a relatively recent environment (MyBinder link), I have no issue.

Corrected snippet:

import salem
from salem import Map, Grid
from pyproj import Proj

g = Grid(nxny=(3, 2), dxdy=(1, 1), x0y0=(0, 0), proj=salem.wgs84)
Map(g)

What did you install your packages with? Conda forge?

@biednick
Copy link
Author

No problem- I figure the more information I provide up front the less time we both have to waste getting up to speed.

The problem could definitely be with one of the downstream packages. I looked into PyProj and GDAL on Windows and see what you mean about a long history of issues. I'd say there's a decent chance your assessment is correct and the issue is with one of them. I can test it in a Linux environment later today, but I'm locked into Windows on the computer I've been working on recently. The binder you linked to isn't loading for me, but I'll try that again later too.

I ran the corrected snippet and had the same error.

I installed all my packages with pip. GDAL was installed from a wheel, but the rest were automatically downloaded from PyPI.

I was able to find a workaround using img = g.get_vardata() and plotting with matplotlib (plt.img_show(img,origin = 'upper', extent = [lat, lat, long, long])). This works well enough for what I am doing but isn't a perfect solution.

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

No branches or pull requests

2 participants