How to fit Matplotlib's stock_img() with Cartopy's NearsidePerspective projectionHow to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?How do you change the size of figures drawn with matplotlib?How do I sort a dictionary by value?How to make a chain of function decorators?How to make a flat list out of list of listsHow do I list all files of a directory?running matplotlib or enthought.mayavi.mlab from a py-shell inside emacs on windows
What is the purpose of this tool?
Which is the current decimal separator?
If I want an interpretable model, are there methods other than Linear Regression?
What is my breathable atmosphere composed of?
What is the mathematical notation for rounding a given number to the nearest integer?
Might have gotten a coworker sick, should I address this?
Why did they ever make smaller than full-frame sensors?
What are uses of the byte after BRK instruction on 6502?
NRF24L01+ changing configuration after startListening
2000s space film where an alien species has almost wiped out the human race in a war
Relocation error involving libgnutls.so.30, error code (127) after last updates
Does an oscilloscope subtract voltages as phasors?
Can a warforged druid use composite plating?
Where to disclose a zero day vulnerability
Maintenance tips to prolong engine lifespan for short trips
How do EVA suits manage water excretion?
Finding the number of digits of a given integer.
Why is the T-1000 humanoid?
Is たらと some form of conditional?
Dehn twist in amalgamated product, preserving a subgroup
A medieval fantasy adventurer lights a torch in a 100% pure oxygen room. What happens?
Is low emotional intelligence associated with right-wing and prejudiced attitudes?
Does my opponent need to prove his creature has morph?
What officially disallows US presidents from driving?
How to fit Matplotlib's stock_img() with Cartopy's NearsidePerspective projection
How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?How do you change the size of figures drawn with matplotlib?How do I sort a dictionary by value?How to make a chain of function decorators?How to make a flat list out of list of listsHow do I list all files of a directory?running matplotlib or enthought.mayavi.mlab from a py-shell inside emacs on windows
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to use Cartopy's proejction NearsidePerspective, but overlaping with the real Earth image provided by Matplotlib, and zooming in a bit by lowering the satellite_height parameter. It appears that Cartopy is not able to trim the image properly for this specific type of setting. The image is displayed still oustide of what one would expect to be the map boundaries.
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(10,10))
# Set Projection
height=3000000
#height=35785831 # this is the default height
projection=ccrs.NearsidePerspective(central_longitude=120,
central_latitude=78,
satellite_height=height)
# Draw
ax = plt.axes(projection=projection)
ax.stock_img()
ax.coastlines(resolution='50m')
plt.show()

How can I combine Matplotlib's stock_img() and this configuration of NearsidePerspective to work properly? Or what would be an alternative way to get the result desired?
I am using Python 3.6 on Jupyter Notebook, Matplotlib 3.0.2, and Cartopy 0.16.0.
python matplotlib map-projections cartopy
add a comment
|
I am trying to use Cartopy's proejction NearsidePerspective, but overlaping with the real Earth image provided by Matplotlib, and zooming in a bit by lowering the satellite_height parameter. It appears that Cartopy is not able to trim the image properly for this specific type of setting. The image is displayed still oustide of what one would expect to be the map boundaries.
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(10,10))
# Set Projection
height=3000000
#height=35785831 # this is the default height
projection=ccrs.NearsidePerspective(central_longitude=120,
central_latitude=78,
satellite_height=height)
# Draw
ax = plt.axes(projection=projection)
ax.stock_img()
ax.coastlines(resolution='50m')
plt.show()

How can I combine Matplotlib's stock_img() and this configuration of NearsidePerspective to work properly? Or what would be an alternative way to get the result desired?
I am using Python 3.6 on Jupyter Notebook, Matplotlib 3.0.2, and Cartopy 0.16.0.
python matplotlib map-projections cartopy
2
For me the map image is cropped correctly. I'm using Python 3.7 on a mac, with matplotlib version 3.0.3 and cartopy version 0.17.0.
– Thomas Kühn
Mar 28 at 11:04
As @ThomasKühn says, it works as expected.
– swatchai
Mar 28 at 11:10
Ok, then it is just probably a local setup/version problem. Thank you for the comments. Would you like to answer the question, pasting the correct image? Or should I just delete the question?
– ouranos
Mar 28 at 11:17
1
Let's leave it as a question. Especially if you can figure out what exactly caused the problem for you and how to fix it (be it a version upgrade or a setup in Jupyter), you can go ahead and edit my answer (I'll make it a community wiki).
– Thomas Kühn
Mar 28 at 11:25
add a comment
|
I am trying to use Cartopy's proejction NearsidePerspective, but overlaping with the real Earth image provided by Matplotlib, and zooming in a bit by lowering the satellite_height parameter. It appears that Cartopy is not able to trim the image properly for this specific type of setting. The image is displayed still oustide of what one would expect to be the map boundaries.
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(10,10))
# Set Projection
height=3000000
#height=35785831 # this is the default height
projection=ccrs.NearsidePerspective(central_longitude=120,
central_latitude=78,
satellite_height=height)
# Draw
ax = plt.axes(projection=projection)
ax.stock_img()
ax.coastlines(resolution='50m')
plt.show()

How can I combine Matplotlib's stock_img() and this configuration of NearsidePerspective to work properly? Or what would be an alternative way to get the result desired?
I am using Python 3.6 on Jupyter Notebook, Matplotlib 3.0.2, and Cartopy 0.16.0.
python matplotlib map-projections cartopy
I am trying to use Cartopy's proejction NearsidePerspective, but overlaping with the real Earth image provided by Matplotlib, and zooming in a bit by lowering the satellite_height parameter. It appears that Cartopy is not able to trim the image properly for this specific type of setting. The image is displayed still oustide of what one would expect to be the map boundaries.
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(10,10))
# Set Projection
height=3000000
#height=35785831 # this is the default height
projection=ccrs.NearsidePerspective(central_longitude=120,
central_latitude=78,
satellite_height=height)
# Draw
ax = plt.axes(projection=projection)
ax.stock_img()
ax.coastlines(resolution='50m')
plt.show()

How can I combine Matplotlib's stock_img() and this configuration of NearsidePerspective to work properly? Or what would be an alternative way to get the result desired?
I am using Python 3.6 on Jupyter Notebook, Matplotlib 3.0.2, and Cartopy 0.16.0.
python matplotlib map-projections cartopy
python matplotlib map-projections cartopy
asked Mar 28 at 10:20
ouranosouranos
1447 bronze badges
1447 bronze badges
2
For me the map image is cropped correctly. I'm using Python 3.7 on a mac, with matplotlib version 3.0.3 and cartopy version 0.17.0.
– Thomas Kühn
Mar 28 at 11:04
As @ThomasKühn says, it works as expected.
– swatchai
Mar 28 at 11:10
Ok, then it is just probably a local setup/version problem. Thank you for the comments. Would you like to answer the question, pasting the correct image? Or should I just delete the question?
– ouranos
Mar 28 at 11:17
1
Let's leave it as a question. Especially if you can figure out what exactly caused the problem for you and how to fix it (be it a version upgrade or a setup in Jupyter), you can go ahead and edit my answer (I'll make it a community wiki).
– Thomas Kühn
Mar 28 at 11:25
add a comment
|
2
For me the map image is cropped correctly. I'm using Python 3.7 on a mac, with matplotlib version 3.0.3 and cartopy version 0.17.0.
– Thomas Kühn
Mar 28 at 11:04
As @ThomasKühn says, it works as expected.
– swatchai
Mar 28 at 11:10
Ok, then it is just probably a local setup/version problem. Thank you for the comments. Would you like to answer the question, pasting the correct image? Or should I just delete the question?
– ouranos
Mar 28 at 11:17
1
Let's leave it as a question. Especially if you can figure out what exactly caused the problem for you and how to fix it (be it a version upgrade or a setup in Jupyter), you can go ahead and edit my answer (I'll make it a community wiki).
– Thomas Kühn
Mar 28 at 11:25
2
2
For me the map image is cropped correctly. I'm using Python 3.7 on a mac, with matplotlib version 3.0.3 and cartopy version 0.17.0.
– Thomas Kühn
Mar 28 at 11:04
For me the map image is cropped correctly. I'm using Python 3.7 on a mac, with matplotlib version 3.0.3 and cartopy version 0.17.0.
– Thomas Kühn
Mar 28 at 11:04
As @ThomasKühn says, it works as expected.
– swatchai
Mar 28 at 11:10
As @ThomasKühn says, it works as expected.
– swatchai
Mar 28 at 11:10
Ok, then it is just probably a local setup/version problem. Thank you for the comments. Would you like to answer the question, pasting the correct image? Or should I just delete the question?
– ouranos
Mar 28 at 11:17
Ok, then it is just probably a local setup/version problem. Thank you for the comments. Would you like to answer the question, pasting the correct image? Or should I just delete the question?
– ouranos
Mar 28 at 11:17
1
1
Let's leave it as a question. Especially if you can figure out what exactly caused the problem for you and how to fix it (be it a version upgrade or a setup in Jupyter), you can go ahead and edit my answer (I'll make it a community wiki).
– Thomas Kühn
Mar 28 at 11:25
Let's leave it as a question. Especially if you can figure out what exactly caused the problem for you and how to fix it (be it a version upgrade or a setup in Jupyter), you can go ahead and edit my answer (I'll make it a community wiki).
– Thomas Kühn
Mar 28 at 11:25
add a comment
|
1 Answer
1
active
oldest
votes
Using the same code on a mac with Python 3.7, Matplotlib 3.0.3, and Cartopy 0.17.0, the image is cropped correctly:

This may either be a version problem or with Jupyter Notebook.
I would expect a closer zoom for the given parameters. If you compare the outer circle of this image, it contains the entire Greenland, for example, while in the image in the question, only the Northernmost tip of Greenland is shown. Is this a different behaviour ofsatellite_heightor did you use a different value?
– ouranos
Mar 28 at 11:33
1
I used the same height value that you posted in your example code. Now I also tried with a tenth of that height, which gives a smaller area, which is still cropped correctly.
– Thomas Kühn
Mar 28 at 11:35
Cartopy 0.17.0 does the trick.
– ouranos
Mar 28 at 14:28
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395163%2fhow-to-fit-matplotlibs-stock-img-with-cartopys-nearsideperspective-projectio%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using the same code on a mac with Python 3.7, Matplotlib 3.0.3, and Cartopy 0.17.0, the image is cropped correctly:

This may either be a version problem or with Jupyter Notebook.
I would expect a closer zoom for the given parameters. If you compare the outer circle of this image, it contains the entire Greenland, for example, while in the image in the question, only the Northernmost tip of Greenland is shown. Is this a different behaviour ofsatellite_heightor did you use a different value?
– ouranos
Mar 28 at 11:33
1
I used the same height value that you posted in your example code. Now I also tried with a tenth of that height, which gives a smaller area, which is still cropped correctly.
– Thomas Kühn
Mar 28 at 11:35
Cartopy 0.17.0 does the trick.
– ouranos
Mar 28 at 14:28
add a comment
|
Using the same code on a mac with Python 3.7, Matplotlib 3.0.3, and Cartopy 0.17.0, the image is cropped correctly:

This may either be a version problem or with Jupyter Notebook.
I would expect a closer zoom for the given parameters. If you compare the outer circle of this image, it contains the entire Greenland, for example, while in the image in the question, only the Northernmost tip of Greenland is shown. Is this a different behaviour ofsatellite_heightor did you use a different value?
– ouranos
Mar 28 at 11:33
1
I used the same height value that you posted in your example code. Now I also tried with a tenth of that height, which gives a smaller area, which is still cropped correctly.
– Thomas Kühn
Mar 28 at 11:35
Cartopy 0.17.0 does the trick.
– ouranos
Mar 28 at 14:28
add a comment
|
Using the same code on a mac with Python 3.7, Matplotlib 3.0.3, and Cartopy 0.17.0, the image is cropped correctly:

This may either be a version problem or with Jupyter Notebook.
Using the same code on a mac with Python 3.7, Matplotlib 3.0.3, and Cartopy 0.17.0, the image is cropped correctly:

This may either be a version problem or with Jupyter Notebook.
answered Mar 28 at 11:23
community wiki
Thomas Kühn
I would expect a closer zoom for the given parameters. If you compare the outer circle of this image, it contains the entire Greenland, for example, while in the image in the question, only the Northernmost tip of Greenland is shown. Is this a different behaviour ofsatellite_heightor did you use a different value?
– ouranos
Mar 28 at 11:33
1
I used the same height value that you posted in your example code. Now I also tried with a tenth of that height, which gives a smaller area, which is still cropped correctly.
– Thomas Kühn
Mar 28 at 11:35
Cartopy 0.17.0 does the trick.
– ouranos
Mar 28 at 14:28
add a comment
|
I would expect a closer zoom for the given parameters. If you compare the outer circle of this image, it contains the entire Greenland, for example, while in the image in the question, only the Northernmost tip of Greenland is shown. Is this a different behaviour ofsatellite_heightor did you use a different value?
– ouranos
Mar 28 at 11:33
1
I used the same height value that you posted in your example code. Now I also tried with a tenth of that height, which gives a smaller area, which is still cropped correctly.
– Thomas Kühn
Mar 28 at 11:35
Cartopy 0.17.0 does the trick.
– ouranos
Mar 28 at 14:28
I would expect a closer zoom for the given parameters. If you compare the outer circle of this image, it contains the entire Greenland, for example, while in the image in the question, only the Northernmost tip of Greenland is shown. Is this a different behaviour of
satellite_height or did you use a different value?– ouranos
Mar 28 at 11:33
I would expect a closer zoom for the given parameters. If you compare the outer circle of this image, it contains the entire Greenland, for example, while in the image in the question, only the Northernmost tip of Greenland is shown. Is this a different behaviour of
satellite_height or did you use a different value?– ouranos
Mar 28 at 11:33
1
1
I used the same height value that you posted in your example code. Now I also tried with a tenth of that height, which gives a smaller area, which is still cropped correctly.
– Thomas Kühn
Mar 28 at 11:35
I used the same height value that you posted in your example code. Now I also tried with a tenth of that height, which gives a smaller area, which is still cropped correctly.
– Thomas Kühn
Mar 28 at 11:35
Cartopy 0.17.0 does the trick.
– ouranos
Mar 28 at 14:28
Cartopy 0.17.0 does the trick.
– ouranos
Mar 28 at 14:28
add a comment
|
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395163%2fhow-to-fit-matplotlibs-stock-img-with-cartopys-nearsideperspective-projectio%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
For me the map image is cropped correctly. I'm using Python 3.7 on a mac, with matplotlib version 3.0.3 and cartopy version 0.17.0.
– Thomas Kühn
Mar 28 at 11:04
As @ThomasKühn says, it works as expected.
– swatchai
Mar 28 at 11:10
Ok, then it is just probably a local setup/version problem. Thank you for the comments. Would you like to answer the question, pasting the correct image? Or should I just delete the question?
– ouranos
Mar 28 at 11:17
1
Let's leave it as a question. Especially if you can figure out what exactly caused the problem for you and how to fix it (be it a version upgrade or a setup in Jupyter), you can go ahead and edit my answer (I'll make it a community wiki).
– Thomas Kühn
Mar 28 at 11:25