contourf plot from csv file on cartopy map - Error: TopologyException: side location conflict at
Description
I am using cartopy to produce a contour plot on a grid. The csv file contains positive and negative float values. I have used code nearly identical to this but have never gotten this error below.
Error
opologyException: side location conflict at 1.0537325376034968e+29 1.0537325376034968e+29 Traceback (most recent call last): File "/home/jwsmith/.conda/envs/glmval/lib/python3.6/site-packages/shapely/predicates.py", line 15, in call return self.fn(this._geom, other._geom, *args) File "/home/jwsmith/.conda/envs/glmval/lib/python3.6/site-packages/shapely/geos.py", line 548, in errcheck_predicate raise PredicateError("Failed to evaluate %s" % repr(func)) shapely.errors.PredicateError: Failed to evaluate <_FuncPtr object at 0x7fa3209f6cc8>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "statsplots_corr_map.py", line 58, in
If you are proposing an enhancement/new feature, provide links to related articles, reference examples, etc.
If you are asking a question, please ask on StackOverflow and use the cartopy tag. All cartopy questions on StackOverflow can be found at https://stackoverflow.com/questions/tagged/cartopy
Code to reproduce
import numpy as np import cartopy.crs as ccrs import cartopy.feature as cfeature from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER import matplotlib.pylab as plt from matplotlib import ticker, cm import pyproj import glob
xcoords = np.loadtxt('./xvals_withheight.csv', delimiter=',', unpack=True) ycoords = np.loadtxt('./yvals_withheight.csv', delimiter=',', unpack=True) ycoords = np.flip(ycoords) xx, yy = np.meshgrid(xcoords,ycoords)
vmax = 1.0 vmin = -1.0 xtcks = np.linspace(vmin, vmax, num=21) levs = np.linspace(vmin, vmax, num=201)
grid = np.load('r_jja_test.npy') grid = np.ma.masked_where(grid < -0.9999, grid)
proj4string = '+units=m +lat_0=0.0 +lon_0=-75.0 +sweep=x +h=35786023.0 +a=6378137 +b=6356752.31414 +proj=geos' proj = pyproj.Proj(proj4string)
xlon, ylat = proj(xx,yy, inverse=True) states_provinces = cfeature.NaturalEarthFeature( category='cultural', name='admin_1_states_provinces_lines', scale='10m', facecolor='none') cmap = cm.seismic plt.figure(figsize=(13,6.2)) ax = plt.subplot(111, projection=ccrs.PlateCarree()) ax.set_extent([-126, -54, 14, 53] , crs=ccrs.PlateCarree()) ax.add_feature(cfeature.LAKES, edgecolor='k', zorder=1) mm = plt.contourf(xlon, ylat, grid, levels = levs, zorder=2, cmap=cmap) print('plot generated and map features being added!') ax.add_feature(states_provinces, edgecolor='k', linewidth= 0.5, zorder=3) ax.add_feature(cfeature.BORDERS, edgecolor='k', zorder=4)
plt.title('JJA 2019 fedminutes and sumfed Correlation Map') plt.colorbar(mm, orientation='vertical',ticks=xtcks,shrink=0.8, format='%1.2f',pad=0.015, spacing='proportional') ax.coastlines('10m', color='k', linewidth=0.5, zorder=5); plt.savefig('./fedminutes_sumfed_r_jja.png', bbox_inches='tight', dpi=600)
plt.clf() ``
#### Traceback
<details>
<summary>Full environment definition</summary>
<!-- fill in the following information as appropriate -->
### Operating system
### Cartopy version
0.17.0
### conda list
### pip list
</details>
This is highly dependent on input data, which you haven't provided.
I just ran into a similar issue. For me it was: TopologyException: side location conflict at 0 0. I don't know what's meant by location 0 0, but I looked at the value in my array at [0,0] and it was -3.832079e-24. The exception went away when I set all values below a threshold to zero (for me the threshold was 0.1, since all values below that are white in my colormap).
It's worth mentioning that I was using scipy.ndimage.zoom on my data to add some more points, and the interpolation often results in many extremely small, but nonzero data values (like the point at 0,0). Until now, I've never had a problem with anything of this sort for lots of different data, colormaps, map domains, and projections, so I would say this is isolated occurrence. Definitely a strange bug to say the least!
My mother is facing a similar issue when using contourf() on a cartopy map. For her, it was 'TopologyException: side location conflict at 67 56.' I am not sure if these are latitude/longitude values or index values for an array. Interestingly, we tried running contour() instead of contourf() and it was able to run successfully. I don't think it is an issue with the values of our Z array itself because there are no outliers. From looking at the same error for PosGIS, it seems like an issue with an invalid polygon that contourf() cannot fill. Perhaps, there is an intersecting line but we don't know. Please let us know if you have any updates! Although it is reassuring that contour() is working, we need to use contourf() for our tasks. Thank you. Python 3.6.3
Description I am using cartopy to produce a contour fill plot on a grid. The script computes probability values from input data set given as a csv file. The code has been successfully running fro two years and has failed 2 times.
Error
TopologyException: side location conflict at 199 45 Traceback (most recent call last): File "/usrx/local/prod/packages/python/3.6.3/lib/python3.6/site-packages/shapely/predicates.py", line 15, in call return self.fn(this._geom, other._geom, *args) File "/usrx/local/prod/packages/python/3.6.3/lib/python3.6/site-packages/shapely/geos.py", line 548, in errcheck_predicate raise PredicateError("Failed to evaluate %s" % repr(func)) shapely.errors.PredicateError: Failed to evaluate <_FuncPtr object at 0x2b0758a6f1d8>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "prob_gefs_northpac.py", line 278, in
Code to reproduce
The code and input data is attached.
#### Traceback
<details>
<summary>Full environment definition</summary>
<!-- fill in the following information as appropriate -->
### Operating system
Linux
Python 3.6.3
### Cartopy version
### conda list
### pip list
</details>
[prob_gefs_northpac.txt](https://github.com/SciTools/cartopy/files/8218490/prob_gefs_northpac.txt)
[prob_storm_data_file.txt](https://github.com/SciTools/cartopy/files/8218492/prob_storm_data_file.txt)
Hi QuLogic: I have a similar issue as stated by jwynnsmith. I have attached the sample program and a test data. Thanks in advance.
This error has recently been coming up for me as well. It only seems to happen when I am using rectangular projections, specifically Mercator.
I had a case when it failed for LambertConformal projection too.
For me the error came up when I changed projection from PlateCarree where it worked, to LambertConformal, where the error occurred without be changing anything else in the Code.
I tried to run the example from @anuappu with current package versions but it failed before it got to the plotting step. Perhaps because pandas has changed something. Since there are no other reproducing examples here, we cannot investigate the issue. So I'm going to close this.
If anyone still has the problem with the latest packages, please open a new issue with a minimal reproducing example.