Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp plotting Geographic Data in R using PBSMapping and Shapefiles
    primarykey
    data
    text
    <p>Using <a href="http://oreilly.com/catalog/9780596804770/" rel="noreferrer">O'Reilly's Data Mashups in R</a> as inspiration, I'm trying to plot a handful of addresses on a shapefile of Salt Lake County, Utah found <a href="http://gis.utah.gov/sgid-vector-download/utah-sgid-vector-gis-data-layer-download-index?fc=CensusTracts2000" rel="noreferrer">here</a>.</p> <p>I have data frame geoTable:</p> <pre><code>&gt; geoTable address Y X EID 1 130 E 300 S 40.76271 -111.8872 1 2 875 E 900 S 40.74992 -111.8660 2 3 2200 S 700 E 40.72298 -111.8714 3 4 702 E 100 S 40.76705 -111.8707 4 5 177 East 200 S 40.76518 -111.8859 5 6 702 3rd ave 40.77264 -111.8683 6 7 2175 S 900 E 40.72372 -111.8652 7 8 803 E 2100 S 40.72556 -111.8680 8 </code></pre> <p>And I've coerced it into an eventData object:</p> <pre><code>&gt; addressEvents&lt;-as.EventData(geoTable,projection=NA) &gt; addressEvents address Y X EID 1 130 E 300 S 40.76271 -111.8872 1 2 875 E 900 S 40.74992 -111.8660 2 3 2200 S 700 E 40.72298 -111.8714 3 4 702 E 100 S 40.76705 -111.8707 4 5 177 East 200 S 40.76518 -111.8859 5 6 702 3rd ave 40.77264 -111.8683 6 7 2175 S 900 E 40.72372 -111.8652 7 8 803 E 2100 S 40.72556 -111.8680 8 </code></pre> <p>So it looks like I've got everything I need to plot-but its not working. When I load the shapefile and plot using</p> <pre><code>addPoints(addressEvents,col="red",cex=.5) </code></pre> <p>I'm left looking at an empty shapefile. Additionally, when I try and run findPolys against my eventData object, it returns NULL.</p> <pre><code>&gt; findPolys(addressEvents,myShapeFile) NULL </code></pre> <p>How can I make this work? I was able to complete the O'Reilly tutorial without any problems and am having difficulty figuring out where I'm going wrong here. I dont know if its the shapefile, my data frame, or whateverelse. </p> <p>Here are the commands I use to import my data and shapefile</p> <pre><code>slc&lt;-read.table('~/utah.txt',sep=',',header=TRUE,strip.white=TRUE,stringsAsFactors=FALSE) myShapeFile&lt;-importShapefile("/Users/neil/Downloads/SGID93_DEMOGRAPHIC_CensusTracts2000/SGID93_DEMOGRAPHIC_CensusTracts2000",readDBF=TRUE) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload