Content
CENSUS TRACT LEVEL
- Installing the arcbinding package
- Checking connections with the ArcGIS Pro software and app versions
- Reading a geodatabase feature class into R
- Bringing selected fields from a geodatabase feature class into R
- Converting your R data frame into a spatial data frame object using the arc.data2sp() function
- Exporting dataframe to CSV
This is a Markdown document on bridging ArcGIS Pro and R. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
Install arcgisbinding and check connections with ArcGIS Pro
library(arcgisbinding)
## *** Please call arc.check_product() to define a desktop license.
arc.check_product()
## product: ArcGIS Pro (13.0.0.36056)
## license: Advanced
## version: 1.0.1.300
Set a working directory
setwd("D:/New Folder/RBridge")
Reading a geodatabase feature class into R
tract_df <- arc.open(path = "D:\\New Folder\\MyProject2\\MyProject2.gdb\\CensusTracts_t_ExportFeature")
Bringing selected fields from a geodatabase feature class into R
tract_select_df <- arc.select(object = tract_df, fields = c('NAME', 'TOTPOP_CY', 'HHPOP_CY', 'FAMPOP_CY', 'GQPOP_CY', 'POPDENS_CY', 'TOTHH_CY', 'AVGHHSZ_CY'))
Convert your R data frame into a spatial data frame object using the arc.data2sp() function
library(sp)
## Warning: package 'sp' was built under R version 4.2.3
tract_spdf <- arc.data2sp(tract_select_df)
Rename columns
col_names <- c("Census_tract", "Total_Populatio",
"Household-Population", "Family_Population", "Group_Quarters_Population",
"Population_Density", "Total_Households", "Average_Household_Size")
Assign renamed columns
colnames(tract_spdf@data) <- col_names
head(tract_spdf@data)
## Census_tract Total_Populatio Household-Population Family_Population
## 1 060190079.03 6899 2366 2131
## 2 060190080.00 4851 4760 3942
## 3 060190081.00 6583 6577 5666
## 4 060190083.01 6199 6196 5303
## 5 060190083.03 4093 4093 3811
## 6 060190083.04 4456 3629 2893
## Group_Quarters_Population Population_Density Total_Households
## 1 4533 9.8 780
## 2 91 767.8 1681
## 3 6 2211.4 2106
## 4 3 467.7 1431
## 5 0 500.9 820
## 6 827 9.0 896
## Average_Household_Size
## 1 3.03
## 2 2.83
## 3 3.12
## 4 4.33
## 5 4.99
## 6 4.05
Write dataframe with renamed columns to CSV
write.csv(tract_spdf@data, file = "TractSelectedRenamed.csv")
Bring in entire tract demographic data - all 9110 raws and 2781 columns
tract_select_df2 <- arc.select(object = tract_df)
Write entire dataframe from the tract demographic geodatabase to CSV
write.csv(tract_select_df2, file = "TractAllFields.csv")