question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider scaling y-axis for unprojected map plots

See original GitHub issue

Following the R&Py workshop https://github.com/rsbivand/ectqg19-workshop, we (me and @darribas) saw that in R, sf scales the y-axis for plotting as a function of the distance between the equator and the middle of the y range of the map https://github.com/r-spatial/sf/blob/8150edb7fbc1e7096526303a6d2876a7b5455260/R/plot.R#L529

#’ The default aspect for map plots is 1; if however data are not #’ projected (coordinates are long/lat), the aspect is by default set to #’ 1/cos(My * pi/180) with My the y coordinate of the middle of the map #’ (the mean of \code{ylim}, which defaults to the y range of bounding box). This #’ implies an \href{https://en.wikipedia.org/wiki/Equirectangular_projection}{Equirectangular projection}.

Unless I’m missing something, https://github.com/geopandas/geopandas/blob/29add0a735b00dc20c79e0fccc8e6a775c4997b0/geopandas/plotting.py#L414 sets 'equal' in all cases. I haven’t found which function you use (through pyproj?) to determin whether the map object is known to be in geographical rather than projected coordinates. Also I don’t know whether a real valued aspect can be passed.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
martinfleiscommented, Oct 13, 2019

Hi @rsbivand,

sorry for slow response. This is quite interesting! You are right that Geopandas currently set aspect to equal in all cases. In 0.6.1 we do not have an option to determine whether gdf is in geographical or projected coordinates. This will change in 0.7 with newly adopted pyproj.CRS (#1101). I think that once we have this change merged, we should definitely consider using the formula above.

I don’t think we support passing aspect either, but that could be done in the same PR.

Thanks!

0reactions
snowman2commented, Jan 25, 2020

Feel free to ignore my other post - after reading what @jorisvandenbossche wrote and re-reading the thread I understand better what is proposed. No issues from my end. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is the figure size (y-axis) fluctuating in this example?
geopandas#1121 - Consider scaling y-axis for unprojected map plots ... .plot() now automatically determines whether GeoSeries (or ...
Read more >
Chapter 2: Scales and Transformations - E-education.psu.edu
Map scale is the proportion between a distance on a map and a ... An example showing how the Cartesian coordinate system works....
Read more >
Drawing beautiful maps programmatically with R, sf and ggplot2
Plots of small regions or projected data will often allow for more accurate scale bars. Country names and other names ( geom_text and...
Read more >
Axes | Chart.js
They are used to determine how data maps to a pixel value on the chart. ... The following chart will have scales 'xAxis'...
Read more >
How to Make Plots — The yt Project 4.1.0 documentation
In this section, “norm” is used as short for “normalization”, and is interchangeable with “scaling”. Map-like plots e.g., SlicePlot , ProjectionPlot and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found