Skip to content
This repository has been archived by the owner on May 1, 2021. It is now read-only.

Updating shapefile #10

Open
rdinter opened this issue Feb 21, 2017 · 0 comments
Open

Updating shapefile #10

rdinter opened this issue Feb 21, 2017 · 0 comments

Comments

@rdinter
Copy link
Contributor

rdinter commented Feb 21, 2017

There's some strange behavior with the default shapefiles in the package that appears to have occurred when the rds files (which have the .rda extension but are rds files...why is that?) were updated with ac3cdf3. It looks like both the county and state shapefiles are of fairly poor quality and produce poor graphics. Let me show the examples and then what I think is happening:

# Splotchy shapefile example

library(albersusa)
library(ggplot2)
library(maptools)
library(sp)

us      <- counties_composite("aeqd")
us_map  <- fortify(us)

ggplot(us_map, aes(long, lat, group = group)) +
  geom_polygon(fill = "blue")

shapefile_issue

(It might be a bit difficult to see, but if you zoom in slightly then the dead pixels become very clear)

This issue is further exacerbated if I try to take the original shapefile, aggregate up to a different level (say states) and create a geom_path:

states <- fortify(us, region = "state")

ggplot(us_map, aes(long, lat, group = group)) +
  geom_polygon(fill = "blue") +
  geom_path(data = states)

shapefile_path_issue

The same performance issues occur with the usa_composite() function for states:

us      <- usa_composite("aeqd")
us_map  <- fortify(us)

ggplot(us_map, aes(long, lat, group = group)) +
  geom_polygon(fill = "blue")

shapefile_issue_states

And if I attempt to create a path for a subset of states:

south_east <- c("AL", "FL", "GA", "NC", "SC")
us$region <- ifelse(us$iso_3166_2 %in% south_east, "SOUTHEAST", "REST")

states <- fortify(us, region = "region")

ggplot(us_map, aes(long, lat, group = group)) +
  geom_polygon(fill = "blue") +
  geom_path(data = states)

shapefile_path_issue_states

Issue

When I went through https://github.com/hrbrmstr/rd3albers to create the Alaska and Hawaii bounding boxes, I noticed that there were two types of formats used for the spatial objects in the repository: the classic .shp/.shx/.dbf shapefile which and also a GeoJSON file. What I am pretty sure is happening is that the current .rda files for counties/states are based off of the GeoJSON file, which has some funky resolution. I'd bet that the previous .rda files were based off of the .shp/.shx/.dbf shapefile, which doesn't appear to produce the funky path lines and splotches while filling in the map.

Are the .rda/.rds files based off of that rd3albers repository? If so, I can put in a pull request here for the objects which uses that repository's data. But further, is there a reason why the counties/states have the .rda extension but are actually .rds based files? That seems a bit confusing to me, but there might be a reason for it that I'm missing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant