earthlab / climate-data-101

4 stars 7 forks source link

cartopy functions crash Colab #10

Open eculler opened 2 years ago

eculler commented 2 years ago

This cell:

central_lat = 37.5
central_lon = -96
extent = [-120, -70, 24, 50.5]
central_lon = np.mean(extent[:2])
central_lat = np.mean(extent[2:])

f, ax = plt.subplots(
    figsize=(12, 6),
    subplot_kw={'projection': ccrs.AlbersEqualArea(central_lon, central_lat)})
ax.coastlines()
ax.plot(
    longitude, latitude,
    markersize=12,
    marker='*',
    color='purple',
    transform=ccrs.PlateCarree())
ax.set_extent(extent)
ax.set(title=("Location of the lat / lon Being Used To to "
              "Slice Your netcdf Climate Data File"))

# Adds a bunch of elements to the map
ax.add_feature(cfeature.LAND, edgecolor='black')

ax.gridlines()
plt.show()

Crashes Colab "for an unknown reason". The runtime logs say:

python3: geos_ts_c.cpp:3991: int GEOSCoordSeq_getSize_r(GEOSContextHandle_t, const geos::geom::CoordinateSequence, unsigned int): Assertion `0 != cs' failed.

The following lines reproduce the crash when included:

eculler commented 2 years ago

Looks like a known issue: https://github.com/SciTools/cartopy/issues/1490 We'll need a "pip install --no-binary shapely shapely --force" at the start

eculler commented 2 years ago

Also !apt-get install -qq libgdal-dev libproj-dev

This works on my version:

# Cartopy needs some other libraries
!apt-get install -qq libgdal-dev libproj-dev
!pip install --no-binary shapely shapely --force
!pip install cartopy