helmingstay / unm-r-programming

This is the permanent website for the University of New Mexico (UNM) R Programming Group, which met from 2012-2014.
0 stars 2 forks source link

Data sources for PR -- geography #3

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Grabbed PR shapefile from here (I used 3 number zip), put in directory 
"shapefiles" and unzip:
http://www2.census.gov/cgi-bin/shapefiles2009/state-files?state=72

Plotting Shapefiles with ggplot2
(this requires that gdal libraries are installed)
https://github.com/hadley/ggplot2/wiki/plotting-polygon-shapefiles

## prelim code
library(ggplot2);
require("rgdal") # requires sp, will use proj.4 if installed
require("maptools")

pr.shp = readOGR(dsn="shapefiles", layer="tl_2009_72_zcta3")

Original issue reported on code.google.com by icos.atr...@gmail.com on 9 Mar 2012 at 10:15

GoogleCodeExporter commented 8 years ago
Ignore the previous comment, it's now out-of-date.
Attached is code that builds a geographic data frame and plots it with ggplot.  

There's also a data file in downloads:
http://unm-r-programming.googlecode.com/files/puerto_rico_shp.RData

I also added a ResearchDay wiki page.  The plotted figure is shown there.

Original comment by icos.atr...@gmail.com on 9 Mar 2012 at 11:55

GoogleCodeExporter commented 8 years ago
Looks like we need a better shapefile for puerto rico.  This one looks like the 
marshmallow man...

Original comment by icos.atr...@gmail.com on 10 Mar 2012 at 12:25

GoogleCodeExporter commented 8 years ago
I may have found a better shapefile. Xian, do you have the code you used to 
produce the map figure? 

Original comment by mjo...@gmail.com on 27 Mar 2012 at 2:13

Attachments:

GoogleCodeExporter commented 8 years ago
Code is now attached.  Note that a bunch of libraries are required to run the 
full build (along with changing the if(F) ).

Original comment by icos.atr...@gmail.com on 27 Mar 2012 at 8:10

Attachments:

GoogleCodeExporter commented 8 years ago
A few things -- 
  * A "shapefile" is really a directory with a bunch of things -- the .shp alone isn't enough
  * I don't understand why, but all the TIGR files are funny -- i tried the same layer you did.
  * I grabbed a full US shapefile here and subsetted for PR, (new source file, RData file, and mostly-poster-ready fig attached): http://www.nws.noaa.gov/geodata/catalog/national/html/us_state.htm

Original comment by icos.atr...@gmail.com on 27 Mar 2012 at 9:24

Attachments:

GoogleCodeExporter commented 8 years ago
I updated the downloads also.

Original comment by icos.atr...@gmail.com on 27 Mar 2012 at 9:38