0

I am having trouble getting Geoplot's Orthographic projection to work near the equator. It works fine at locations ±90 longitude where latitude is right at 0, but if I run the code below, it fails the try blocks if -90 < longitude < 90 when latitude is at or near 0. In addition, at the prime meridian, the try blocks will fail if latitude is as high as 6.5 or as low as -0.2.

Why? What's wrong with the projection?

The problem with Geoplot is the same when I use Cartopy directly, as Geoplot is built on top of Cartopy.

#Imported packages for the geographic part of the program
import geopandas as gpd
import matplotlib.pyplot as plt
import urllib.request as ur
import geoplot as gpl
import geoplot.crs as gcrs
from shapely.geometry import Point

#Imported packages for the graphical interface part of the program
import tkinter as tk
from tkinter import *

#Function for the geographic part of the program
def show_map(lon, lat):
    #Parameters (longitude and latitude centres of the projection)
    lonctr = lon
    latctr = lat
    centrepoint = Point(lonctr, latctr)

#<snip>----------------------------------

    #Creating a world map and ensuring the map is limited by the orthographic
    #projection
    themap = plt.figure("World Map")

    #Preparing projected data for the Natural Earth file to be plotted
    #on the axes using geoplot
    try:
        check = 1
        themap = plt.subplot(111,projection=gcrs.Orthographic(central_longitude=lonctr,
            central_latitude=latctr))
        land = gpl.polyplot(earth, projection=gcrs.Orthographic(central_longitude=lonctr,
            central_latitude=latctr), linewidth=1, edgecolor="white", facecolor="blue",
            zorder=1, ax=themap)
        dot = gpl.pointplot(newdata, projection=gcrs.Orthographic(central_longitude=lonctr,
            central_latitude=latctr), s=20, color="red", marker="o", zorder=4, ax=themap)
    except:
        themap = plt.subplot(111,projection=gcrs.PlateCarree(central_longitude=lonctr))
        land = gpl.polyplot(earth, projection=gcrs.PlateCarree(central_longitude=lonctr),
            linewidth=1, edgecolor="white", facecolor="blue", zorder=1, ax=themap)
        dot = gpl.pointplot(newdata, projection=gcrs.PlateCarree(central_longitude=lonctr),
            s=20, color="red", marker="o", zorder=4, ax=themap)

    #Using projected data from overlay file to be plotted on the axes
    #using geoplot
    try:
        if(check == 1):
            polyover = gpl.polyplot(overlay, projection=gcrs.Orthographic(central_longitude=lonctr,
                central_latitude=latctr), linewidth=1, edgecolor="white", facecolor="pink",
                zorder=2, ax=themap)
        else:
            polyover = gpl.polyplot(overlay, projection=gcrs.PlateCarre(central_longitude=lonctr), linewidth=1,
                edgecolor="white", facecolor="pink", zorder=2, ax=themap)
    except:
        pass
    try:
        if(check == 1):
            pointover = gpl.pointplot(overlay, projection=gcrs.Orthographic(central_longitude=lonctr,
                central_latitude=latctr), s=20, color="green", marker="o", zorder=3, ax=themap)
        else:
            pointover = gpl.pointplot(overlay, projection=gcrs.PlateCarree(central_longitude=lonctr),
                s=20, color="green", marker="o", zorder=3, ax=themap)                  
    except:
        pass

    check = 0

#<snip>----------------------------------

Beyond ±90 longitude is okay Within ±90 throws the error At prime meridian, can get as close as 6.5 N But can't get closer than 6.5 N at prime meridian Can get as close as 0.3 S at prime meridian But can't get closer than 0.3 S at prime meridian

-2

my thoughts are it's in the ax=themap extents, my take is the calculation of projection coordinates seems to fall outside the ax extents, given the diff lat/long coordinates. I used a your code and plugged the lat/long in directly and the ax extents were out of bounds. Using -90/0 coordinates gave:

...:Failed to determine the required bounds in projection coordinates.

Check that the values provided are within the valid range (x_limits=[-6378073.21863, 6378073.21863], y_limits=[-6378073.21863, 6378073.21863]).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.