Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:58
    AlxndrLhr closed #2086
  • Sep 29 18:47
    dopplershift commented #2080
  • Sep 29 11:39
    jorisvandenbossche commented #2080
  • Sep 28 08:19
    jorisvandenbossche synchronize #2080
  • Sep 27 20:51
    jorisvandenbossche commented #2080
  • Sep 27 20:50
    jorisvandenbossche synchronize #2080
  • Sep 27 18:58
    dopplershift closed #879
  • Sep 27 18:58
    dopplershift commented #879
  • Sep 27 18:54
    dopplershift closed #2090
  • Sep 27 18:54
    dopplershift commented #2090
  • Sep 27 16:16
    cameronbracken commented #879
  • Sep 27 16:12
    cameronbracken commented #879
  • Sep 27 14:09
    4goettma opened #2090
  • Sep 27 07:35
    QuLogic closed #2088
  • Sep 27 07:30
    PBrockmann commented #2088
  • Sep 27 05:46
    jrenaud90 opened #2089
  • Sep 26 23:28
    dopplershift commented #2087
  • Sep 26 23:27
    dopplershift commented #2088
  • Sep 26 18:00
    PBrockmann edited #2088
  • Sep 26 17:57
    PBrockmann opened #2088
Leonardo
@leonardojimenez1990
Thank you very much @dopplershift . I have not been able to install proj 8. Do you know a way to install proj 8?
Successfully built cartopy
Installing collected packages: cartopy
Successfully installed cartopy-0.19.0.post1
Greg Lucas
@greglucas
Their install page lists the many ways to install it: https://proj.org/install.html
Miles Engel
@Pheosics
Does anyone have any experience with creating satellite coverage maps using cartopy? I've managed to figure out how to properly change map projections and things like that, but anytime I attempt to apply a transformation to a patch or a ShapelyFeature I don't get anything.
Ryan May
@dopplershift
I've not done anything like that before. Would need to see a complete, self-contained example to try to debug.
Greg Lucas
@greglucas
Yes, I work with plotting satellite data and passes. Have you binned your data into a grid and are trying to plot that? Or trying to plot the ground tracks of satellites? My guess is that if you are not able to transform anything is that you're using the incorrect transform for your data coordinates. If you have lat/lon ground tracks use the PlateCarree/Geodetic input to the function call, and then whatever projection you want in the Axes() creation calls. But, remember the transform=data for the plotting function calls.
Miles Engel
@Pheosics
test_0000.gif
What I have is the TLE of a satellite (or the actual ephemeris data, depending on the satellite) and would like to plot a field of view coverage area (assuming some fixed field of view), the circle gets plotted, but it doesn't get properly transformed to account for the geodetic Earth
Greg Lucas
@greglucas
You may want to look at the Nightshade implementation which follows the subsolar point and handles some curvatures in that way. https://scitools.org.uk/cartopy/docs/latest/gallery/lines_and_polygons/nightshade.html https://github.com/SciTools/cartopy/blob/main/lib/cartopy/feature/nightshade.py
Miles Engel
@Pheosics
Thanks, I will look at that. I also found this example, https://scitools.org.uk/cartopy/docs/v0.10/examples/geostationary.html, which seems to take a circular image and uses the Geostationary reference frame to transform it into a more expected shape. I'm guessing this won't work for an arbitrary satellite location, but maybe I can figure out something by looking at that code
Ryan May
@dopplershift
@Pheosics That example is using the transform framework to transform the image (which has circular extent) to the desired Miller projection for the map. For arbitrary satellite location, you might also be interested in NearsidePerspective.
Miles Engel
@Pheosics
Hmm, NearsidePerspective does seem to be what I want... it looks like it can take the lat/lon/alt of the satellite and do a transformation. The projected coordinates are supposed to be an x,y measured from the origin of the plane tangent to the Earth directly below the satellite. That should be easy enough to calculate. I'm guessing thats x,y in meters?
Ryan May
@dopplershift
Correct. I'm still curious why that isn't what happens to the circle patch, though.
Greg Lucas
@greglucas
image.png
I'm confused now... I think it does happen for the Circle() patch.
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

fig, ax = plt.subplots(subplot_kw={"projection": ccrs.Robinson()})

ax.coastlines()
patch = plt.Circle((140, 20), 20, color='g',
                   alpha=0.5, transform=ccrs.PlateCarree().as_geodetic())
ax.add_patch(patch)
ax.set_global()

plt.show()
Miles Engel
@Pheosics
interesting, that is what I expected to see, but not what I was seeing in my code, the only thing I can see as different is instead of the transform using ccrs.PlateCarree().as_geodetic() I just used ccrs.Geodetic()
Greg Lucas
@greglucas
Should be the same thing I think. Yours is just the quicker version :) Note that all of the Circle parameters are then in degrees, including the radius, which may or may not be what you want.
Miles Engel
@Pheosics
hmm, that could have been the issue, I will have to investigate tomorrow when I am back in front of the computer. Thank you both for your help, I'll update tomorrow with whatever I was doing wrong
Miles Engel
@Pheosics
So it seems like my issue was that I was using the PlateCarree projection with a Geodetic transformation which didn't alter the shape of the circle. Using Robinson and Geodetic did alter the circle in a way consistent with the coordinate transformation, but also made me realize that I will either need to figure out NearsidePerspective or perform a more detailed calculation for determining the view coverage as a circle doesn't just become a rounded rectangle by coordinate transformation, but instead by field of view mapping
Ryan May
@dopplershift
@Pheosics Having gone through the math for all that, you may be better off just copying the code in NearsidePerspective/Satellite that calculates that boundary.
Miles Engel
@Pheosics
looks like NearsidePerspective gives me what I need (or at least something that looks a lot like what I need). The only tricky thing is that if your radius is too large it just won't plot anything. Luckily it seems my calculation of the circle from before is enough to limit the radius to something it will correctly plot
test_NP.gif
Ryan May
@dopplershift
@Pheosics I'm not sure what your radius represents? The math in NearsidePerspective is calculating based on tangent lines for a given satellite height.
Miles Engel
@Pheosics
By radius I mean the radius of the circle that is formed when you draw a cone from the satellite down to a tangent plane which is centered right below the satellite. Of course if the satellite is far away or has a large enough look angle, the circle formed will be larger than the cross section of the Earth, so you have to limit it. In an ideal world NearsidePerspective would handle that, but it seems like it doesn't and so if you create a circle with too large of radius and try and use NearsidePerspective to display it it will just not display anything.
Ryan May
@dopplershift
So Nearside perspective is calculating purely where the line from the satellite is tangent to the surface of the earth—so the physical limit one can see without looking through rock. It’s not using any kind of field of view limit from the satellite.
George Duffy
@CowboyGeorge

Hello. I just installed Cartopy on a new MacOS Pro 13", running Monterey. I just tried to copy the tutorial script "https://scitools.org.uk/cartopy/docs/latest/gallery/lines_and_polygons/always_circular_stereo.html", and I'm getting an error at the line where i'm supposed to apply cfeature.LAND,
"PermissionError: [Errno 13] Permission denied: '~/.local/share/cartopy'"

I don't have "cartopy" directory in /.local/share/, which seems like problem. I've tried reinstalling to no avail (using the conda forge), and I haven't seen any similar problems on stack overflow or anything similar. Any ideas on what could be going wrong?

Ryan May
@dopplershift
Cartopy should create the directory cartopy inside ~/.local/share, where ~ is your user home directory. I'd check the permissions on ~/.local/share.
George Duffy
@CowboyGeorge

Thanks Ryan,

I did find that my ~/.local/share directory had root permissions, which is also strange since according to the person who set up my permission there wasn't even a ~/.local directory on my computer when received it. The directory was empty, so I deleted the directory and made a new one (~./local/share) with user permission, but when I installed it with conda it just tells me that "All requested packages already installed", with no new files created inside ~./local/share.

Greg Lucas
@greglucas
I'm not sure whether conda installs anything to that directory when you install, but if you run that example again, it should give you some "DownloadWarnings" that populate that directory with the needed files.
George Duffy
@CowboyGeorge
Tutorial is working! Thank you!
George Duffy
@CowboyGeorge
image.png
image.png
anuappu
@anuappu
Hello: I am a a beginner in Python/cartopy etc so pardon my ignorance. I am encountering an error when I utilize the cointourf utility. Toplology exception side conflict error.
Snippet of my code
 ax = plt.axes(projection=ccrs.LambertConformal(central_longitude=10.0, central_latitude=40.0, standard_parallels=(40.0, 40.0)))
I am a bit confused on what the ax.extent transform should be:
ax.set_extent([-30, 40, 25, 70],crs=ccrs.???())
and finally sc=plt.contourf(xnew, ynew, perc, clevs,
transform=ccrs.PlateCarree(),colors=colours,extend='max')
where xnew is lon and lat in degrees and perc is probability values that I am computing.
anuappu
@anuappu
The code works 95% of the time but once in while fails with a an error "Toplology exception side conflict error at .."
The input data and the calculated probability values seem correct.
Appreciate the feedback.
Greg Lucas
@greglucas
Yes, it looks like there are some bad transformations going on creating invalid geometries at some point in the chain. No one has addressed that issue yet. You can try "transform_first=True" to the contouring algorithm which may lead to nicer geometries... See: https://scitools.org.uk/cartopy/docs/latest/gallery/scalar_data/contour_transforms.html
anuappu
@anuappu
Thank you @greglucas for the quick response. The "transform_first=True" did not work. However, may I ask, you mention that "bad transformations going on creating invalid geometries at some point in the chain" could it be in the way the ax.extent is defined?
Greg Lucas
@greglucas
Yes, it certainly could be, you can try adjusting the limits to see if that helps.
anuappu
@anuappu
Thanks, I will try that and keep you posted.
anuappu
@anuappu
@greglucas I have not have had any success with the issue by altering the ax.extent limits. Is it fair to say the it could be the conflict between the projection of LambertConformal and the transformation to PlateCaree? Also, the area where I am trying to project crosses the 0 longitude (domain includes both the hemispheres). Any suggestions would really be appreciated.
Greg Lucas
@greglucas
Yes, it is very likely bad transformation with some points in a Polygon, and that object being cut/stitched back together incorrectly. No one has found the cause of this yet in that issue, so unfortunately there isn't much we can do until the root cause is determined. One other thought is to try adjusting your contouring levels, which will produce different sets of coordinates.
anuappu
@anuappu
Thanks @greglucas
Alexandre ROULEAU
@arouleau56

Hello everyone, I trie to apply the second cell of this link https://www.geophysique.be/2014/02/25/shaded-relief-map-in-python/

See the code here :

Subplot 2: STRM Map

plt.figure(figsize=(15, 10))
ax = plt.subplot(111, projection=ccrs.PlateCarree())

elev, crs, extent = srtm_composite(12, 47, 1, 1)
elev = np.ma.masked_less_equal(elev,0,copy=False)
plt.imshow(elev, extent=extent, transform=crs,
cmap='gist_earth', origin='lower')

However I got these message : "HTTP Error 401: Unauthorized".
Do you have an idea howto solve it?
Thank you :)

Ryan May
@dopplershift
I'm not even sure how that code could run that far? srtm_composite was removed in CartoPy 0.12 according to the changelog