matplotlib / matplotlib/basemap
lat_0, lon_0 ignored
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 817
- Forks
- 395
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I am trying to set up Basemap to use a Cylindrical Equal Area projection and to place the origin at a specific lat/lon (this is to match some input x/y data that uses a false easting/northing), but it seems that setting the lat_0 and lon_0 parameters does nothing.
from mpl_toolkits.basemap import Basemap
# Oklahoma bounds
# ('o' = origin at corner of Kingfisher/Logan/Canadian/Oklahoma counties)
lats = {'n': 37.1, 's': 33.6, 'c': 35.5, 'o': 35.726}
lons = {'e': -94.4, 'w': -103.0, 'c': -97.5, 'o': -97.674}
buf = 0.05 # plot buffer size (in degrees)
res = 'c' # map shapes resolution
# projection parameters
proj = 'cea' # cylindrical equal area
lat_ts = lats['c'] # true scale at geographic center
lon_0 = lons['o'] # x=0 at counties corner
lat_0 = lats['o'] # y=0 at counties corner
m = Basemap(projection = proj, lat_ts = lat_ts, resolution = res,
lon_0 = lon_0, lat_0 = lat_0,
urcrnrlon = lons['e'] + buf, urcrnrlat = lats['n'] + buf,
llcrnrlon = lons['w'] - buf, llcrnrlat = lats['s'] - buf*4)
Then checking the origin gives:
In [15]: m(0, 0, inverse=True)
Out[15]: (-103.05000000000305, 33.399999999963455)
...which is the lower-left corner of the map bounds, not the coordinates I gave for lat_0 and lon_0. I get the same output if I leave out lat_0 and lon_0 entirely.
At first, I thought maybe the CEA projection doesn't support these parameters and that I should just shift my data manually, but the docs claim that lat_0 and lon_0 are used by all projections to set the origin.
As a workaround, I can set an offset to get the intended results:
offset = m(lon_0, lat_0)
df['x'], df['y'] = (df.x + offset[0], df.y + offset[1]) # where df is a Pandas dataframe with my data
Note: Originally posted to StackOverflow, where I was encouraged to move the issue here. http://stackoverflow.com/questions/31302427/lat-0-lon-0-ignored-by-basemap
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Einrichtung der Basemap-Projektion und den Einstiegspunkten für die Koordinatenkonvertierung, und führe dann das bereitgestellte Cylindrical Equal Area-Beispiel mit und ohne lat_0 und lon_0 aus. Überprüfe, ob m(0, 0, inverse=True) den angegebenen Ursprung berücksichtigt, statt die unteren linken Kartengrenzen zurückzugeben; abgeschlossen ist die Untersuchung, wenn das Verhalten den dokumentierten Parametern entspricht oder die Einschränkung eindeutig festgestellt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100