Skip to content

Instantly share code, notes, and snippets.

@ohnorobo
Last active August 29, 2015 14:16
Show Gist options
  • Save ohnorobo/2718c0238c3dcc941dab to your computer and use it in GitHub Desktop.
Save ohnorobo/2718c0238c3dcc941dab to your computer and use it in GitHub Desktop.
example of segfault in mpl basemap
from mpl_toolkits.basemap import Basemap
# works
boundaries = (42.88679, 41.187053, -69.858861, -73.508142)
north, south, east, west = boundaries
b = Basemap(projection="lcc",
llcrnrlon=west,
llcrnrlat=south,
urcrnrlon=east,
urcrnrlat=north,
lat_0=(south+north)/2,
lon_0=(east+west)/2)
#Errors correctly
'''
# RuntimeError: conic lat_1 = -lat_2
'''
boundaries = (90, -90, 180, -180)
north, south, east, west = boundaries
b = Basemap(projection="lcc",
llcrnrlon=west,
llcrnrlat=south,
urcrnrlon=east,
urcrnrlat=north,
lat_0=(south+north)/2,
lon_0=(east+west)/2)
# Segfaults
'''
$ python breakexample.py
GEOS_ERROR: TopologyException: Input geom 1 is invalid: Self-intersection at or near point -355 89.999638676664148 at -355 89.999638676664148
[1] 62852 segmentation fault python breakexample.py
$ python3 breakexample.py
GEOS_ERROR: b'%s'
[1] 62912 segmentation fault python3 breakexample.py
'''
boundaries = (90, -80, 180, -170)
north, south, east, west = boundaries
b = Basemap(projection="lcc",
llcrnrlon=west,
llcrnrlat=south,
urcrnrlon=east,
urcrnrlat=north,
lat_0=(south+north)/2,
lon_0=(east+west)/2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment