Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move alaska, hawaii, and puerto rico into frame with lower 48 states all in an albers #167

Closed
wants to merge 4 commits into from

Conversation

andy-esch
Copy link
Contributor

This function projects U.S. states and Puerto Rico into a frame that's easy to view for election maps, etc.

Sample usage:

update states_table
set the_geom = CDB_AlbersUSA(the_geom,state_identifier)

Produces a map like this:

screen shot 2015-09-28 at 21 56 55

I'm looking for feedback on:

  1. Choosing appropriate projections
  2. Placement and scale of the states
  3. Whether more state identifiers should be listed for the second argument

cc @makella @andrewxhill

@andrewxhill
Copy link

Does it work line your example, overwriting thegeom, it does it only work
if you alias the result as thegeomweb?
On Sep 29, 2015 12:58 AM, "Andy Eschbacher" notifications@github.com
wrote:

This function projects U.S. states and Puerto Rico into a frame that's
easy to view for election maps, etc.

Sample usage:

update states_tableset the_geom = CDB_AlbersUSA(the_geom,state_identifier)

Produces a map like this:

[image: screen shot 2015-09-28 at 21 56 55]
https://cloud.githubusercontent.com/assets/1041056/10155575/e142a8ce-662b-11e5-88d4-e98792563abe.png

I'm looking for feedback on:

  1. Choosing appropriate projections
  2. Placement and scale of the states
  3. Whether more state identifiers should be listed for the second
    argument

cc @makella https://github.com/makella @andrewxhill

https://github.com/andrewxhill

You can view, comment on, or merge this pull request online at:

#167
Commit Summary

  • first
  • refactored
  • project to wgs84 instead
  • fixed output errors

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#167.

@andy-esch
Copy link
Contributor Author

I can easily change it to be agnostic to the input geometry, which might be more natural: the srid you put in is the srid you get out.

updating the_geom_webmercator works if it's transformed:

update states_table
set the_geom_webmercator = ST_Transform(CDB_AlbersUSA(the_geom,state_identifier),3857)

But that doesn't trigger the_geom column to be recalculated.

@andrewxhill
Copy link

Yep, got it got, I missed the srid parameter. Looks great!

On Tue, Sep 29, 2015 at 12:12 PM, Andy Eschbacher notifications@github.com
wrote:

I can easily change it to be agnostic to the input geometry, which might
be more natural: the srid you put in is the srid you get out.

updating the_geom_webmercator works if it's transformed:

update states_tableset the_geom_webmercator = ST_Transform(CDB_AlbersUSA(the_geom,state_identifier),3857)

But that doesn't trigger the_geom column to be recalculated.


Reply to this email directly or view it on GitHub
#167 (comment)
.

andrewxhill http://twitter.com/andrewxhill
http://cartodb.com

@andy-esch
Copy link
Contributor Author

@rochoa @javisantana, what do you think of this? Also, how should I test it?

@javisantana
Copy link
Contributor

Why this needs to be a function in the extension and not a table in common data?

@andy-esch
Copy link
Contributor Author

Yeah. Where should I save this function for later reference, then?

@andrewxhill
Copy link

Because any user that wants to transform their own data to match will need
to perform the same transform exactly. (Imagine any point dataset)
On Oct 2, 2015 12:04 PM, "javi santana" notifications@github.com wrote:

Why this needs to be a function in the extension and not a table in common
data?


Reply to this email directly or view it on GitHub
#167 (comment)
.

@javisantana
Copy link
Contributor

I think we should do something more generic here, we know a lot of countries have this problem, so why now having a table with the codes <-> transformations (and projection), like

CDB_Country('spain', the_geom, admin_identifier)
CDB_Country('usa', the_geom, admin_identifier)

and the a table like

create table cdb_countries (
  name text,
  region text,
  offset, 
  projection_srid
)

maybe sounds overkill but adding so concrete functionality to a core extension seems weird (not against it tho)

@andy-esch
Copy link
Contributor Author

Ok, I'll:

  • make a list of candidate countries (or continents) that could use this type of transformation
  • look into the 'standard' way to alter the projection
  • fit it into the format proposed above

@makella
Copy link

makella commented Oct 19, 2015

@ohasselblad there was a comment from Cindy B about the Census maps that she was a part of making... apparently AK (the state itself) prefers to have AK above the contiguous US. I know you and I had discussed the idea of having a couple of different layouts for templates including what USGS and Census do.

On a design note: she also said that I should make sure to shadow in Canada, Mexico in the background.

Example of one her maps:

screen shot 2015-10-19 at 8 34 34 am

@andrewxhill
Copy link

i see this working when you have control of the non-map layout too, but for
more generic purposes i feel like we still need to move alaska below. space
packing + familiarity

On Mon, Oct 19, 2015 at 8:39 AM, Mamata Akella notifications@github.com
wrote:

@ohasselblad https://github.com/ohasselblad there was a comment from
Cindy B about the Census maps that she was a part of making... apparently
AK (the state itself) prefers to have AK above the contiguous US. I know
you and I had discussed the idea of having a couple of different layouts
for templates including what USGS and Census do.

On a design note: she also said that I should make sure to shadow in
Canada, Mexico in the background.

Example of one her maps:

[image: screen shot 2015-10-19 at 8 34 34 am]
https://cloud.githubusercontent.com/assets/1566273/10577844/41e17a0a-763c-11e5-90da-fbc0766331af.png


Reply to this email directly or view it on GitHub
#167 (comment)
.

andrewxhill http://twitter.com/andrewxhill
http://cartodb.com

@andy-esch
Copy link
Contributor Author

And I did make Alaska larger than it is in most other projections like this!
On Mon, Oct 19, 2015 at 6:26 AM Andrew W. Hill notifications@github.com
wrote:

i see this working when you have control of the non-map layout too, but for
more generic purposes i feel like we still need to move alaska below. space
packing + familiarity

On Mon, Oct 19, 2015 at 8:39 AM, Mamata Akella notifications@github.com
wrote:

@ohasselblad https://github.com/ohasselblad there was a comment from
Cindy B about the Census maps that she was a part of making... apparently
AK (the state itself) prefers to have AK above the contiguous US. I know
you and I had discussed the idea of having a couple of different layouts
for templates including what USGS and Census do.

On a design note: she also said that I should make sure to shadow in
Canada, Mexico in the background.

Example of one her maps:

[image: screen shot 2015-10-19 at 8 34 34 am]
<
https://cloud.githubusercontent.com/assets/1566273/10577844/41e17a0a-763c-11e5-90da-fbc0766331af.png


Reply to this email directly or view it on GitHub
<
#167 (comment)

.

andrewxhill http://twitter.com/andrewxhill
http://cartodb.com

Reply to this email directly or view it on GitHub
#167 (comment)
.

@nerik
Copy link

nerik commented Apr 18, 2016

Hey there, I'm happy to unearth this :)
I've been using this, very useful and thank you
https://team.cartodb.com/u/nerikcarto/viz/36e410e6-0574-11e6-9b33-0e31c9be1b51/embed_map

One thing that is noticed when mapping the Zika outbreak: american territories are missing (American Samoas and US Virgin Islands). They are important, no?

This would be awesome if merged - even with only the USA, but a with generic name.

@nerik
Copy link

nerik commented May 12, 2016

A quick way to add separator lines :

    -- puerto rico
    SELECT ST_Transform(ST_GeomFromText('LINESTRING(13 1.5,16 3)', 4236), 3857) as the_geom_webmercator
    union all
    -- hawaii
    SELECT ST_Transform(ST_GeomFromText('LINESTRING(-12 7.8,-5 1.6)', 4236), 3857) as the_geom_webmercator
    union all
    -- alaska
    SELECT ST_Transform(ST_GeomFromText('LINESTRING(-21 10,-9 -1)', 4236), 3857) as the_geom_webmercator

screen shot 2016-05-12 at 19 19 14

@Algunenano
Copy link
Contributor

Stale

@Algunenano Algunenano closed this Nov 6, 2019
@Algunenano Algunenano deleted the albers-proj branch November 15, 2019 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants