Comments (9)
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.
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.
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.
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.
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.
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.
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.
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.
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)
- install basemap HOT 2
- matplotlib < 3.7 requirement? HOT 3
- basemap with mac m2 issues HOT 32
- Function "addcyclic": IndexError HOT 2
- ETOPO failed to show with pseudocyl projection HOT 3
- Issue with basemap installation on cygwin HOT 16
- Problem with installation on linux/arm64 conda environment HOT 10
- Basemap installation failure in MacOS - Jupyter Notebook HOT 5
- Any way to control shapefile alpha? HOT 2
- show a warning when projection is wrongly parameterized
- Geoslib Import HOT 3
- Segmentation Fault due To build conflicts HOT 2
- AttributeError: module 'numpy' has no attribute 'float'. HOT 7
- Basemap install fails after python upgrade HOT 4
- arcgisimage doesn't work HOT 4
- FAQ refers to file that was replaced HOT 2
- AttributeError: can't set attribute HOT 5
- Basemap fails to install using pip on macOS (M1) HOT 3
- Basemap: solving environment failed HOT 4
- shiftdata docs reverse return values HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from basemap.