cartopy

How to add a point-feature shapefile to map using cartopy

我与影子孤独终老i 提交于 2019-12-21 04:54:15
问题 I have two shapefiles. One is a point feature shapefile, named "point.shp", the other is a polygon shapefile named "polygon.shp". Both I want to add to a map using cartopy. I managed to add the "polygon.shp", but failed with the "point.shp". Here's my code: import matplotlib.pyplot as plt from cartopy import crs from cartopy.io.shapereader import Reader from cartopy.feature import ShapelyFeature ax = plt.axes(projection=crs.PlateCarree()) # add the polygon file, worked ax.add_geometries

How can I show a km ruler on a cartopy / matplotlib plot?

跟風遠走 提交于 2019-12-20 12:02:11
问题 How can I show a km ruler for a zoomed in section of a map, either inset in the image or as rulers on the side of the plot? E.g. something like the 50 km bar on the side (left) or the inset in mi (right): (sources: 1, 2) (issue: cartopy#490) 回答1: Here's the Cartopy scale bar function I wrote for my own use which uses simpler version of pp-mo's answer: Edit: modified code to create a new projection centred so that the scale bar is parallel to the axies for many coordinate systems, including

Matplotlib projection remove margin

坚强是说给别人听的谎言 提交于 2019-12-20 05:14:57
问题 Here's an image of US counties, created on top of ax = plt.axes(projection=ccrs.LambertConformal()) ax.set_extent([-120, -70, 20, 50], ccrs.Geodetic()) In the "live" figure one can see with plt.show() , there's a large gray area around the figure. Here you can (not) see it via the white padding. So I thought I could zoom in a bit more: ax.set_extent([-120, -70, 20, 40], ccrs.Geodetic()) And then this happened: While there is still white margin/padding around the figure, it's suddenly cropped.

Python 3.4 crashes when producing some – but not all – Cartopy maps with segmentation fault 11

坚强是说给别人听的谎言 提交于 2019-12-19 19:52:30
问题 I have installed the Python mapping tool Cartopy on a Mac running El Capitan 10.11.6 with Python 3.4. I can use Cartopy to successfully plot some maps but, in some cases, the Python kernel dies with Segmentation Fault 11. I wanted a setup that I could remove easily from my computer should the need arise. Therefore, I installed Python 3.4 and the necessary dependencies using fink: $ fink install python34 $ fink install gdal2 $ fink install gdal2-dev $ fink install proj $ fink install libproj9

Polar Stereographic projection of geopandas world map

会有一股神秘感。 提交于 2019-12-14 02:29:38
问题 I want to use the geopandas included low resolution world map (see here) as a background for my data. This works fine as long as I use e.g. 'PlateCarree' projection. If I now want to use a polar stereographic peojection ccrs.NorthPolarStereo() or ccrs.SouthPolarStereo() It does not work. My code looks like this (using python 3) import geopandas as gpd import cartopy.crs as ccrs crs = ccrs.NorthPolarStereo() crs_proj4 = crs.proj4_init world = gpd.read_file(gpd.datasets.get_path("naturalearth

Plotting projected data in other projectons using cartopy

自作多情 提交于 2019-12-13 13:25:56
问题 This question is in regards to plotting some data I have that uses the Lambert Conformal (LCC) CRS. While these questions specifically pertain to plotting LCC data in multiple projections, it also applies to the use of cartopy in general in that I would like to better understand the logic/process of plotting using cartopy. Below are some code examples of what I am trying to do. The first example is simply plotting some LCC data. The data I used are available in the link here. import cartopy

How to calculate geodesic distance along a path (lat/lon points) at once?

孤街浪徒 提交于 2019-12-13 03:22:45
问题 Using Python 3.7 with Jupyter Notebook on a Win10 x64. I have a list of lat-long tuples representing a path and I want to calculate the total length along that path in meters. I would like to avoid calculating each segment distance and then adding them all together as I have to do this for 7 million paths. So time efficiency is key. Adding all segments after computing individual distances takes 7ms per path. I want to make it at least 1ms fast. Edit: I need to calculate distances using the

Cartopy + Matplotlib (contourf) - Map Overriding data

有些话、适合烂在心里 提交于 2019-12-12 03:52:59
问题 I'm trying to do a Contour Plot having the Global Map in background. Having in mind that my data have LON and LAT values, I decided to use Cartopy with MatplotLib. The problem is that I can plot my data and the map perfectly when separated, but when I try to integrate the data with the map the Cartopy map override my data plot. This is my code: ax = plt.axes(projection=cartopy.crs.PlateCarree()) v = np.linspace(0, 80, 25, endpoint=True) cp = plt.contourf(matrixLon, matrixLat, matrixTec, v,

Plotting a straight line in Cartopy, Robinson projection

我只是一个虾纸丫 提交于 2019-12-11 19:14:36
问题 I'm playing around with cartopy trying to understand how it works. The first thing I tried was very similar to the example in the docs under the 'Adding Data to the Map' section. I'm trying to draw a straight line from Adelaide, Australia to Liverpool, UK on my Robinson projection. This is my code: import cartopy.crs as ccrs import matplotlib.pyplot as plt ax = plt.axes(projection=ccrs.Robinson()) ax.coastlines() ax.stock_img() ad_lat, ad_lon = -34.93, 138.60 liv_lat, liv_lon = 53.41, -2.99

Why can't one set to “False” specific axis ticklabels (ex: xlabels_top, ylabels_right) from a cartopy-geopandas plot?

可紊 提交于 2019-12-11 18:32:16
问题 I am having serious difficulties in setting to False the xlabels_top and ylabels_right from my Geopandas plot. This geopandas plot is made inside a Geoaxes subplot created with PlateCarree projection from Cartopy library. My geopandas Geodataframe is in SIRGAS 2000 (units: degrees), EPSG: 4989. Therefore I created a Geodetic Globe object from the cartopy library. Here is a code snippet: import matplotlib.pyplot as plt import cartopy.crs as ccrs import geopandas as gpd Geopandas_DF = gpd.read