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

Admin 1 features incompletely drawn in some cases #1155

Closed
mhearne-usgs opened this issue Oct 24, 2018 · 2 comments
Closed

Admin 1 features incompletely drawn in some cases #1155

mhearne-usgs opened this issue Oct 24, 2018 · 2 comments
Milestone

Comments

@mhearne-usgs
Copy link
Contributor

Description

Admin level 1 Natural Earth features are incompletely drawn in some cases - the script below creates a map showing the border between Illinois and Indiana, but that ends before the bottom of the map where Illinois, Indiana, and Kentucky all meet. Attached is a map of the same data from Natural Earth plotted in QGIS, with the junction of the three states being shown.
screen shot 2018-10-24 at 4 21 38 pm

Code to reproduce

#!/usr/bin/env python


import cartopy.crs as ccrs  # projections
import cartopy.feature as cfeature
import matplotlib.pyplot as plt

BORDER_ZORDER = 1110

if __name__ == '__main__':
    bounds = (-88.76666666666667, -86.93333333333334,
              37.73333333333333, 39.18333333333333)
    figsize = (10.0, 9.947416426343834)
    xmin, xmax, ymin, ymax = bounds
    clon = (xmin + xmax) / 2
    if xmax < 0 and xmax < xmin:
        clon = (xmin + (xmax+360))/2

    clat = (ymin + ymax) / 2
    proj = ccrs.Mercator(central_longitude=clon,
                         min_latitude=ymin,
                         max_latitude=ymax,
                         globe=None)
    geoproj = ccrs.PlateCarree()
    figure = plt.figure(figsize=figsize)

    aspect = 0.9941078696774519

    # Note: dimensions are: [left, bottom, width, height]
    dim_left = 0.1
    dim_bottom = 0.19
    dim_width = 0.8
    dim_height = dim_width/aspect

    dimensions = [dim_left, dim_bottom, dim_width, dim_height]

    ax = figure.add_axes(dimensions, projection=proj)
    ax.set_extent([xmin, xmax, ymin, ymax], crs=geoproj)
    states_provinces = cfeature.NaturalEarthFeature(
        category='cultural',
        name='admin_1_states_provinces_lines',
        scale='10m',
        facecolor='none')

    ax.add_feature(states_provinces, edgecolor='black', zorder=BORDER_ZORDER)
    plt.savefig('maptest.png')

Traceback


Full environment definition

Operating system

Cartopy version

conda list

pip list

@QuLogic
Copy link
Member

QuLogic commented Oct 25, 2018

This seems to have something to do with the thresholding; you can get it to work by patching it with proj._threshold /= 6.

The threshold is determined by the x limits, but should probably check the y limits as well. I don't really know how the threshold calculation was chosen though, so I'm not sure what the best calculation should be there (just doing the same thing would produce a threshold much much smaller than 1/6).

@QuLogic
Copy link
Member

QuLogic commented Oct 25, 2018

I think it also works fine if you take out min_latitude because then it's not clipping that close to the map border.

QuLogic added a commit to QuLogic/cartopy that referenced this issue Oct 28, 2018
When vertical limits are very small, but horizontal limits are wide, the
threshold is too large, and can clip some elements that should be
visible.

Fixes SciTools#1155.
QuLogic added a commit to QuLogic/cartopy that referenced this issue Oct 29, 2018
When vertical limits are very small, but horizontal limits are wide, the
threshold is too large, and can clip some elements that should be
visible.

Fixes SciTools#1155.
@QuLogic QuLogic added this to the 0.17 milestone Oct 30, 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

2 participants