Open JasonSills opened 3 years ago
Sure, check your variable names before the geojson_write() step.
names( sea ) %>% sort()
Have you double-merged datasets, which results in some variable names with the suffix var.x and var.y?
That was creating this error for another student. I would revisit the dataset and make sure you are only adding census data once, and that you are not duplicating merge steps.
Interesting. I'm only seeing both one time for the variable mhmval12. There is also a pop00.x, but no pop00.y.
If this was a double-merging issue wouldn't I see it with multiple variables?
Can you email me your RMD for your data steps?
Alright, this error occurs when you drop a tract at some stage.
If you have N tracts in your shapefile then the polygon and data frame row IDs are both labeled 1:N.
If you drop a tract then either the data frame rows or the polygon IDs are getting renames 1:(N-1) while the other is just skipping a number. This causes a mis-alignment of IDs between the polygons and data frame (which is how the sp package matches data between the two).
So you might have to align IDs by assigning the polygon IDs as row names before writing to file:
library( geojsonio )
# data frame and polygon ID standardization in case a tract was dropped and IDs don't match
row.ids <- sapply( slot( phx_dorling, "polygons" ), function(x) slot( x, "ID" ) )
row.names( phx_dorling ) <- row.ids
phx <- spTransform( phx, CRS("+proj=longlat +datum=WGS84") )
geojson_write( phx, file="phx_dorling.geojson", geometry="polygon" )
Hi @lecy,
Wondering if you can help clarify the error Error in sp::SpatialPolygonsDataFrame(polys, data = input@data) : row.names of data and Polygons IDs do not match
I receive this at the end of constructing my dataset to import to the dashboard.
Here is my code:
It seems that this is indicating a data merging error. However, I'm able to create a cartogram with the 2000 median home value calculation, so that appears to work.
I'm merging with:
Where the y="geoid" was created from the census data using a regex to match to the GEOID.