-
Notifications
You must be signed in to change notification settings - Fork 361
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
RuntimeError: Unidentified problem with geometry, linestring being re-added. #655
Comments
Thanks @DamienIrving - looks like it is a geometry transformation bug that needs addressing. It can get tricky to track this down, but I've got a few notes on how I've done some of the tracking down in the past: https://github.com/SciTools/cartopy/wiki/DEVEL:-Isolating-misbehaving-polygons-in-cartopy's-matplotlib-interface Essentially, we want to reduce the scope of the problem to as few coordinates as possible. After that, I try to get hold of the If that sounds a little too involved, if you could get to the point of getting hold of your x, y, data arrays, and the exact coordinate systems you are using (thereby removing Iris as a dependency), and I'll try to help (though I'm going to be away from civilisation for a few weeks in a few days). Cheers, |
I also get this message with the following code fig = plt.figure(figsize=(10,10))
ax = plt.axes(projection=ccrs.InterruptedGoodeHomolosine(central_longitude=100))
#ax.set_extent((110, 155, -45, -5))
ax.coastlines(resolution='10m')
ax.gridlines(draw_labels=False)
ax.add_feature(cartopy.feature.LAND)
ax.add_feature(cartopy.feature.OCEAN)
ax.add_feature(cartopy.feature.COASTLINE)
shp = shapereader.Reader(add_shp)
add_s = shp.records()
ADD_alpha = 0.5
for add in add_s:
if( add.geometry == None):
pass
else:
ax.add_geometries([add.geometry], ccrs.PlateCarree(),\
edgecolor='red', facecolor='white', alpha = ADD_alpha)
#end if
#end for
plt.show() where the shape file being added is from https://github.com/fraxen/tectonicplates add_shp = '../data/PB2002_plates' the error message is ---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
D:\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
305 pass
306 else:
--> 307 return printer(obj)
308 # Finally look for special method names
309 method = get_real_method(obj, self.print_method)
D:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in <lambda>(fig)
225
226 if 'png' in formats:
--> 227 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
228 if 'retina' in formats or 'png2x' in formats:
229 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
D:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
117
118 bytes_io = BytesIO()
--> 119 fig.canvas.print_figure(bytes_io, **kw)
120 data = bytes_io.getvalue()
121 if fmt == 'svg':
D:\Anaconda3\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2178 orientation=orientation,
2179 dryrun=True,
-> 2180 **kwargs)
2181 renderer = self.figure._cachedRenderer
2182 bbox_inches = self.figure.get_tightbbox(renderer)
D:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)
525
526 def print_png(self, filename_or_obj, *args, **kwargs):
--> 527 FigureCanvasAgg.draw(self)
528 renderer = self.get_renderer()
529 original_dpi = renderer.dpi
D:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in draw(self)
472
473 try:
--> 474 self.figure.draw(self.renderer)
475 finally:
476 RendererAgg.lock.release()
D:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
60 def draw_wrapper(artist, renderer, *args, **kwargs):
61 before(artist, renderer)
---> 62 draw(artist, renderer, *args, **kwargs)
63 after(artist, renderer)
64
D:\Anaconda3\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
1157 dsu.sort(key=itemgetter(0))
1158 for zorder, a, func, args in dsu:
-> 1159 func(*args)
1160
1161 renderer.close_group('figure')
D:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
60 def draw_wrapper(artist, renderer, *args, **kwargs):
61 before(artist, renderer)
---> 62 draw(artist, renderer, *args, **kwargs)
63 after(artist, renderer)
64
D:\Anaconda3\lib\site-packages\cartopy\mpl\geoaxes.py in draw(self, renderer, inframe)
370
371 return matplotlib.axes.Axes.draw(self, renderer=renderer,
--> 372 inframe=inframe)
373
374 def __str__(self):
D:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
60 def draw_wrapper(artist, renderer, *args, **kwargs):
61 before(artist, renderer)
---> 62 draw(artist, renderer, *args, **kwargs)
63 after(artist, renderer)
64
D:\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
2317
2318 for zorder, a in dsu:
-> 2319 a.draw(renderer)
2320
2321 renderer.close_group('axes')
D:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
60 def draw_wrapper(artist, renderer, *args, **kwargs):
61 before(artist, renderer)
---> 62 draw(artist, renderer, *args, **kwargs)
63 after(artist, renderer)
64
D:\Anaconda3\lib\site-packages\cartopy\mpl\feature_artist.py in draw(self, renderer, *args, **kwargs)
158 if ax.projection != feature_crs:
159 projected_geom = ax.projection.project_geometry(
--> 160 geom, feature_crs)
161 else:
162 projected_geom = geom
D:\Anaconda3\lib\site-packages\cartopy\crs.py in project_geometry(self, geometry, src_crs)
173 raise ValueError('Unsupported geometry '
174 'type {!r}'.format(geom_type))
--> 175 return getattr(self, method_name)(geometry, src_crs)
176
177 def _project_point(self, point, src_crs):
D:\Anaconda3\lib\site-packages\cartopy\crs.py in _project_multipolygon(self, geometry, src_crs)
289 geoms = []
290 for geom in geometry.geoms:
--> 291 r = self._project_polygon(geom, src_crs)
292 if r:
293 geoms.extend(r.geoms)
D:\Anaconda3\lib\site-packages\cartopy\crs.py in _project_polygon(self, polygon, src_crs)
324 # Convert any lines to rings by attaching them to the boundary.
325 if multi_lines:
--> 326 rings.extend(self._attach_lines_to_boundary(multi_lines, is_ccw))
327
328 # Resolve all the inside vs. outside rings, and convert to the
D:\Anaconda3\lib\site-packages\cartopy\crs.py in _attach_lines_to_boundary(self, multi_line_strings, is_ccw)
506 if debug_plot_edges:
507 plt.show()
--> 508 raise RuntimeError('Unidentified problem with '
509 'geometry, linestring being '
510 're-added. Please raise an issue.')
RuntimeError: Unidentified problem with geometry, linestring being re-added. Please raise an issue. environment is: python version : 3.5.2 |Anaconda custom (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] |
This is also a problem that I frequently face when attempting to plot 2m-temperature error in an
The contour levels I supply are Since the temperature data are supplied in real-time, I've made a local copy of today's file in order to spend some time diagnosing the issue. I'll also be happy to share the file with someone else who would like to reproduce it. |
Both examples are fixed by #974. |
I got the same problem when run: import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
plt.figure(figsize=(12, 8))
ax = plt.axes(projection=ccrs.EuroPP())
land = cfeature.NaturalEarthFeature(category='physical', name='land', scale='50m',
facecolor=cfeature.COLORS['land'])
ocean = cfeature.NaturalEarthFeature(category='physical', name='ocean', scale='50m',
facecolor=cfeature.COLORS['water'])
ax.add_feature(ocean)
ax.add_feature(land)
ax.gridlines(linestyle=':')
plt.show() By the way, I'm using Cartopy 0.15.0, Python 3.5.4 on Windows 10. |
I've documented a case at this IPython notebook where I get a
RuntimeError: Unidentified problem with geometry, linestring being re-added
error when using thecontourf
function.In the notebook you'll see that I'm transforming data from a
ccrs.RotatedPole(260, 20)
grid to accrs.RotatedPole(260, 20, central_rotated_longitude=180)
grid. This error doesn't happen every time I attempt this transform with thecontourf
function, so I'm at a loss as to why this specific data file throws an error.(it looks like this
Unidentified problem with geometry
error is something others have found in the past - e.g. #311 - but perhaps it hasn't been fully resolved?)The text was updated successfully, but these errors were encountered: