Giter Club home page Giter Club logo

Comments (9)

guziy avatar guziy commented on May 22, 2024

Here is a small workaround for you:

from mpl_toolkits import basemap
from matplotlib.lines import Line2D
import matplotlib.pyplot as plt

m1 = basemap.Basemap(projection='cea', lon_0=0)
m1.drawcoastlines()
lon = [-135, -45, 45, 135]
lat = [45, 45, 45, 45]

x, y = m1(lon[:2], lat[:2])
ax = plt.gca()
ax.plot(*m1(lon[:2], lat[:2]))

This way (without latlon=True) the problematic function is not called... Probably latlon=True is there only for large arrays, and I suppose ideally even uniform..

Cheers

from basemap.

guziy avatar guziy commented on May 22, 2024

Actually this also works fine:

from mpl_toolkits import basemap

m1 = basemap.Basemap(projection='cea', lon_0=0)
m1.drawcoastlines()
lon = [-135, -45, 45, 135]
lat = [45, 45, 45, 45]

m1.plot(*m1(lon[:2], lat[:2]))

from basemap.

guziy avatar guziy commented on May 22, 2024

I think a good fix would be to check the latlon=True and the length of the arrays and throw an exception if the length is less than 3, with an explanation like: latlon=True is only for uniform grids with lots of points...

from basemap.

jakevdp avatar jakevdp commented on May 22, 2024

Is latlon=True really only for a uniform grid? I've been using it pretty regularly for any input – I assumed that it basically means "call m(x, y) automatically", and it seems to act that way for arrays longer than 2 elements.

from basemap.

guziy avatar guziy commented on May 22, 2024

Actually it is also calling shiftdata and the shiftdata is kind of limited, here is the doc to shiftdata:

def shiftdata(self,lonsin,datain=None,lon_0=None):
    """ Shift longitudes
    (and optionally data) so that they match map projection region. Only valid
    for cylindrical/pseudo-cylindrical global projections and data on regular
    lat/lon grids. longitudes and data can be 1-d or 2-d, if 2-d it is assumed
    longitudes are 2nd (rightmost) dimension.
    """

It actually might work for nonuniform grids, but I am not sure if it is
bulletproof...

from basemap.

guziy avatar guziy commented on May 22, 2024

Duplicating the code here, I could not make it highlighted above, probably because I sent it using email...

    def shiftdata(self,lonsin,datain=None,lon_0=None):
        """ Shift longitudes
        (and optionally data) so that they match map projection region. Only valid
        for cylindrical/pseudo-cylindrical global projections and data on regular
        lat/lon grids. longitudes and data can be 1-d or 2-d, if 2-d it is assumed
        longitudes are 2nd (rightmost) dimension.
        """

from basemap.

guziy avatar guziy commented on May 22, 2024

I am pretty sure that shiftdata is not needed for scatter, so I've created a PR for that, but I am not sure about plot though...

from basemap.

WeatherGod avatar WeatherGod commented on May 22, 2024

You need it for plot so that a path drawn around over the pacific doesn't
look like it crosses the Atlantic, for example.

On Thu, Aug 27, 2015 at 3:20 PM, Huziy Oleksandr (Sasha) <
[email protected]> wrote:

I am pretty sure that shiftdata is not needed for scatter, so I've created
a PR for that, but I am not too sure about plot though...


Reply to this email directly or view it on GitHub
#126 (comment).

from basemap.

pwolfram avatar pwolfram commented on May 22, 2024

We have also encountered issues using latlon=True and I'm wondering if it wouldn't hurt to tighten up the documentation to note some of these complexities with its use. It appears a better practice to not use it if possible. However, for someone just starting to use basemap, it is very appealing and further instructions on its usage would be helpful to avoid the issues we were having in MPAS-Dev/geometric_features#14.

from basemap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.