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

Drawing an inset map in a separate axes sometimes causes "RuntimeError: Unidentified problem with geometry, linestring being re-added." #863

Closed
mhearne-usgs opened this issue Feb 27, 2017 · 9 comments

Comments

@mhearne-usgs
Copy link
Contributor

mhearne-usgs commented Feb 27, 2017

Platform: Mac OS 10.10.5
Python: 3.6.0 | packaged by conda-forge | (default, Feb 10 2017, 07:08:35)
Cartopy Version: 0.15.0

Below is a script that causes the error: "Unidentified problem with geometry, linestring being re-added." in crs.py.

Notice that there are other regions (I've included one) in the world where drawing this inset map does NOT cause this error.

#!/usr/bin/env python

import numpy as np
import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs  # projections

WATERCOLOR = '#7AA1DA'

#This region in the phillipines causes no errors
#xmin,xmax,ymin,ymax = (122.460700,128.460700,6.967600,12.877600)

#this region in india causes an error
xmin,xmax,ymin,ymax = (90.6505, 96.6505, 22.080346634631709, 27.526853365368289)


clon = (xmin + xmax)/2
clat = (ymin + ymax)/2
width = (xmax-xmin)*np.cos(np.radians(clat))*111.191
height = (ymax-ymin)*111.191
aspect = width/height
FIGWIDTH = 7.0
figheight = FIGWIDTH/aspect
bbox = (xmin,ymin,xmax,ymax)
bounds = (xmin,xmax,ymin,ymax)
figsize = (FIGWIDTH,figheight)

proj = ccrs.Mercator(central_longitude=clon,
                     min_latitude=ymin,
                     max_latitude=ymax,
                     globe=None)
geoproj = ccrs.PlateCarree()

figure = plt.figure(figsize=figsize)
ax = figure.add_axes([0,0,1,1],projection=proj)
ax.set_extent([xmin, xmax, ymin, ymax],crs=geoproj)

#normally I would do interesting things here, but they're not germane to 
#reproducing the problem

corner_rect = (0.84999999999999987,
               0.012441587723185982,
               0.14000000000000001,
               0.13930240350766115)

clat2 = round(clat)
clon2 = round(clon)

#draw a little globe in the corner showing in small-scale where the earthquake is located.
proj = ccrs.Orthographic(central_latitude=clat2,
                         central_longitude=clon2)

ax2 = figure.add_axes(corner_rect,projection=proj)

#in at least one area in the world (India), this raises an exception once you draw or save
ax2.add_feature(cartopy.feature.OCEAN, zorder=0,facecolor=WATERCOLOR,edgecolor=WATERCOLOR)

plt.savefig('test.png')
@mhearne-usgs mhearne-usgs changed the title Drawing an inset map as a separate axis sometimes causes "RuntimeError: Unidentified problem with geometry, linestring being re-added." Drawing an inset map in a separate axes sometimes causes "RuntimeError: Unidentified problem with geometry, linestring being re-added." Feb 27, 2017
@mhearne-usgs
Copy link
Contributor Author

If there is a work-around for this, I'd be happy to hear about that! :)

@mhearne-usgs
Copy link
Contributor Author

@ajdawson I hate to single you out specifically on this, but I notice you've responded to a couple of other issues since mine, and I thought perhaps you would have some guidance on my issue. If you look at my example, I'm not actually trying to render any of my own datasets, just the ocean feature that comes with Cartopy. It seems to me that this is kind of a problem for the project - is there a particular person who is best suited to address this sort of issue?

@dopplershift
Copy link
Contributor

I can say that this script reproduces the problem for me on osx, Python 3.6, cartopy 0.14.3 from conda-forge.

@ajdawson
Copy link
Member

ajdawson commented Mar 8, 2017

This looks like a transform problem, we have seen these here and there, but I don't know what is wrong specifically. You probably want the assistance of @pelson or @QuLogic

@mhearne-usgs
Copy link
Contributor Author

@pelson @QuLogic Is this an issue that either of you have any guidance on? As I pointed out above, it's not a problem with data that I am introducing, but data that comes with Cartopy.

@marqh
Copy link
Member

marqh commented Mar 21, 2017

this is a problem and i'd like to get it fixed. there are other open issues regarding line string adding

@mhearne-usgs if you fancy giving me a head start, you could look into writing a test inside cartopy.tests which fails in this way, based on your example

i'll try to get onto looking at this as soon as i can

@mhearne-usgs
Copy link
Contributor Author

@marqh I've forked cartopy, and have added a test. Looked at documentation on contributing and can't find any specific guidance there on how to set up my system for development or running tests.

@marqh
Copy link
Member

marqh commented Apr 7, 2017

hi @mhearne-usgs

i have not looked into this in detail yet

I use conda to establish test environments, you can look in the .travis.yml for clues, it is a small par tof what that file does

there are continuous integration tests running on this repository, so you can just write what looks like a sensible test case, and include it in one of the test modules, for example:
https://github.com/SciTools/cartopy/blob/master/lib/cartopy/tests/crs/test_mercator.py
as a new test function. if you propose this as a PR, the nice folks at travis will run the tests and report on your test case for us

@QuLogic
Copy link
Member

QuLogic commented Jan 3, 2018

Fixed by #974.

@QuLogic QuLogic closed this as completed Jan 3, 2018
@QuLogic QuLogic added this to the 0.16 milestone Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants