How to use R to plot 3D graph with zip maps from Arcview on X-Y plane?

What you need on your computer

  • Arcview
  • R 1.7.1 for Windows

    How to do it?

  • If the Arcview shape files' table file ( .dbf ) does not have columns containing x,y coordinates, i.e. when you open the shape file in Arcview, the attribute table does not have x,y coordinates as attributes, then you need to
  • Close Arcview and open R 1.7.1
  • Choose Install package(s) from CRAN... from Packages, select shapefiles and scatterplot3d from the select window, click OK
  • Download plot3d.r and follow the comments in plot3d.r to make some minor changes of input and output folders
  • Run plot3d.r in R Console by type in source("path of plot3d.r/plot3d.r"), then the 3D plot plot3d.ps will be generated in the folder where you specified in plot3d.r

    Remarks:

  • The shapefiles has to be in polygons or points to support the addxycoo.ave
  • Before running addxycoo.ave, make sure that the data is the active theme and the view is the last active window before returning to the Script window. This is because the code calls theView = av.GetActiveDoc, and Arcview takes the last active winodw before returning to Script window to be the active window
  • I'm using Windows R because it has a more convenient tool to update packages

    Example

    This example illustrates how to get that 3D plot using Rochester county map.
  • Download shape files for Rochester county and save under c:/.
  • Close Arcview and open R 1.7.1
  • Choose Install package(s) from CRAN... from Packages, select shapefiles and scatterplot3d from the select window, click OK
  • Download plot3d.r to M:/public_html/PLOT3D
  • Run plot3d.r in R Console by type in source("M:/public_html/PLOT3D/plot3d.r"), then the 3D plot plot3d.ps will be generated under M:/public_html/PLOT3D

    Another Example

    This example illustrates how to get that 3D plot using Minnesota county map.
  • Download shape files for Minnesota county and save under c:/.
  • Close Arcview and open R 1.7.1
  • Choose Install package(s) from CRAN... from Packages, select shapefiles and scatterplot3d from the select window, click OK
  • Download plot3dmn.r to M:/public_html/PLOT3D
  • Run plot3dmn.r in R Console by type in source("M:/public_html/PLOT3D/plot3dmn.r"), then the 3D plot plot3dmn.ps will be generated under M:/public_html/PLOT3D

    Remark:

  • To save space, the minnesota.dbf downloaded from above link has already the X-coord and Y-coord columns inside. You can simply open it in Excel to delete them. It won't cause problem when you open the minnesota.shp in Arcview.
  • What I found here is that after submittimg source("M:/public_html/PLOT3D/plot3dmn.r") in R, when you open the generated plot3dmn.ps in gsview32 or some other software, you may find that the 3D plot is incomplete, there may be some zips or counties missing. Now you need to close R to let R write its buffer to the .ps file to make it complete.