DS4PS / cpp-529-spr-2021

Course shell for CPP 529 Community Analytics
http://ds4ps.org/cpp-529-spr-2021/
2 stars 0 forks source link

Problem saving my Cartogram... or any cartogram #22

Closed Sean-In-The-Library closed 2 years ago

Sean-In-The-Library commented 3 years ago

I was trying to save my cartogram based on the instructions from Lab 4 and I keep hitting this wall. Initially I tried it with the county that I was using but couldn't figure it out so I tried it with the example give (PHX). Still no luck. I can't figure out what I'm missing here.

Here's the portion that I get stuck on:

phx <- merge( phx, phx.pop, by.x="GEOID", by.y="GEOID" ) phx <- merge( phx, phx.mhhi, by.x="GEOID", by.y="GEOID" ) head( phx@data ) %>% pander()

Error: (pictured below)

Error in head(phx@data) : trying to get slot "data" from an object (class "sf") that is not an S4 object

image

Unfortunately this bottlenecks my progress making the map so that I can save it, render it, etc. I could manually make the map for the final but I'd prefer to do this if possible. Any ideas friends? or Dr. Howell?

I've clearly failed on the "Make sure that your map file is an sp “spatial object” file type and not an sf “simple features” file type" portion but I can't figure out how to convert it properly. @Anthony-Howell-PhD

AntJam-Howell commented 3 years ago

Hi Sean, if you are wanting to download the spatial features of the census data, you will need to have geography=TRUE.

Best,

On Sun, Apr 25, 2021 at 11:29 AM Sean H. @.***> wrote:

I was trying to save my cartogram based on the instructions from Lab 4 and I keep hitting this wall. Initially I tried it with the county that I was using but couldn't figure it out so I tried it with the example give (PHX). Still no luck. I can't figure out what I'm missing here.

Here's the portion that I get stuck on:

phx <- merge( phx, phx.pop, by.x="GEOID", by.y="GEOID" ) phx <- merge( phx, phx.mhhi, by.x="GEOID", by.y="GEOID" ) head( @.*** ) %>% pander()

Error: (pictured below)

Error in @.***) : trying to get slot "data" from an object (class "sf") that is not an S4 object

[image: image] https://user-images.githubusercontent.com/60198848/116004679-a96d2500-a5b8-11eb-9c42-bc4868af2dff.png

Unfortunately this bottlenecks my progress making the map so that I can save it, render it, etc. I could manually make the map for the final but I'd prefer to do this if possible. Any ideas friends? or Dr. Howell? @Anthony-Howell-PhD https://github.com/Anthony-Howell-PhD

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DS4PS/cpp-529-spr-2021/issues/22, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMK2Y77IC5LTXZRGRDQNAETTKRNOTANCNFSM43RRF5UQ .

-- Anthony Howell Asst. Prof. in Public Policy School of Public Affairs Arizona State University Faculty Profile https://sustainability.asu.edu/person/anthony-howell/ (CV https://www.dropbox.com/s/b1pxccpwxm6fats/Howell.CV.pdf?dl=0)

Sean-In-The-Library commented 3 years ago

Oops, duh. That was a dumb oversight and thank you, @Anthony-Howell-PhD

But it's still not working for me.

image

I even tried st_transform because I saw it on a stackoverflow-type site when other people had this problem.

image

lecy commented 3 years ago

The map objects can be sp or sf objects. Yours looks like an sf object but should be sp to export it.

there is a casting step you are missing.check back over the original tutorial for that step.

lecy commented 3 years ago

Step 4

https://ds4ps.org/cpp-529-spr-2021/LABS/lab-04-instructions.html

Sean-In-The-Library commented 3 years ago

@lecy OK, I'll give that a try. Thank you!