Texas county outlines

Mapping
Texas
A file of Texas county outline polygons in EPSG:4326
Author

Alan Jackson

Published

March 19, 2020

Create an sf file of Texas county outlines

Note that merges are best done with FIPs codes and not with the county names, as even state agencies can’t get the county names right. Classic example is De Witt county, frequently misspelled by leaving out the blank (DeWitt).

Read in and examine input file

Texas county outlines

https://gis-txdot.opendata.arcgis.com/datasets/texas-county-boundaries-line

Retrieved 19 Mar 2020 as a gdb

directory: Texas_County_Boundaries

path <- "/home/ajackson/Dropbox/Rprojects/Datasets/Texas_County_Boundaries_gdb/"

# Read the feature class
Counties <- st_read(paste0(path, "4d61e1c90493475db4bbff0f229a9bcf.gdb"),
                    stringsAsFactors = FALSE)
Reading layer `County' from data source 
  `/home/ajackson/Dropbox/Rprojects/Datasets/Texas_County_Boundaries_gdb/4d61e1c90493475db4bbff0f229a9bcf.gdb' 
  using driver `OpenFileGDB'
Simple feature collection with 254 features and 9 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -11871800 ymin: 2978934 xmax: -10409240 ymax: 4369694
Projected CRS: WGS 84 / Pseudo-Mercator
summary(Counties)
 CMPTRL_CNTY_NBR    CNTY_NM           DPS_CNTY_NBR    FIPS_ST_CNTY_CD   
 Min.   :  1.00   Length:254         Min.   :  1.00   Length:254        
 1st Qu.: 64.25   Class :character   1st Qu.: 64.25   Class :character  
 Median :127.50   Mode  :character   Median :127.50   Mode  :character  
 Mean   :127.50                      Mean   :127.50                     
 3rd Qu.:190.75                      3rd Qu.:190.75                     
 Max.   :254.00                      Max.   :254.00                     
 TXDOT_CNTY_NBR   TXDOT_DIST_NBR       GID          SHAPE_Length   
 Min.   :  1.00   Min.   : 1.00   Min.   :  1.00   Min.   : 93641  
 1st Qu.: 64.25   1st Qu.: 6.00   1st Qu.: 64.25   1st Qu.:234060  
 Median :127.50   Median :12.00   Median :127.50   Median :256402  
 Mean   :127.50   Mean   :12.19   Mean   :127.50   Mean   :284618  
 3rd Qu.:190.75   3rd Qu.:18.00   3rd Qu.:190.75   3rd Qu.:304714  
 Max.   :254.00   Max.   :25.00   Max.   :254.00   Max.   :728747  
   SHAPE_Area                  SHAPE    
 Min.   :5.474e+08   MULTIPOLYGON :254  
 1st Qu.:3.001e+09   epsg:3857    :  0  
 Median :3.402e+09   +proj=merc...:  0  
 Mean   :3.764e+09                      
 3rd Qu.:3.765e+09                      
 Max.   :2.138e+10                      
#   unproject the data to lat longs on proper datum

Counties <- st_transform(Counties, googlecrs)

summary(Counties)
 CMPTRL_CNTY_NBR    CNTY_NM           DPS_CNTY_NBR    FIPS_ST_CNTY_CD   
 Min.   :  1.00   Length:254         Min.   :  1.00   Length:254        
 1st Qu.: 64.25   Class :character   1st Qu.: 64.25   Class :character  
 Median :127.50   Mode  :character   Median :127.50   Mode  :character  
 Mean   :127.50                      Mean   :127.50                     
 3rd Qu.:190.75                      3rd Qu.:190.75                     
 Max.   :254.00                      Max.   :254.00                     
 TXDOT_CNTY_NBR   TXDOT_DIST_NBR       GID          SHAPE_Length   
 Min.   :  1.00   Min.   : 1.00   Min.   :  1.00   Min.   : 93641  
 1st Qu.: 64.25   1st Qu.: 6.00   1st Qu.: 64.25   1st Qu.:234060  
 Median :127.50   Median :12.00   Median :127.50   Median :256402  
 Mean   :127.50   Mean   :12.19   Mean   :127.50   Mean   :284618  
 3rd Qu.:190.75   3rd Qu.:18.00   3rd Qu.:190.75   3rd Qu.:304714  
 Max.   :254.00   Max.   :25.00   Max.   :254.00   Max.   :728747  
   SHAPE_Area                  SHAPE    
 Min.   :5.474e+08   MULTIPOLYGON :254  
 1st Qu.:3.001e+09   epsg:4326    :  0  
 Median :3.402e+09   +proj=long...:  0  
 Mean   :3.764e+09                      
 3rd Qu.:3.765e+09                      
 Max.   :2.138e+10                      
# Let's do a little cleanup

Counties <- Counties %>% rename(County=CNTY_NM)

Plot data

plot(Counties[,"County"])

Save data

path <- "/home/ajackson/Dropbox/Rprojects/Datasets/Archive/"

# saveRDS(Counties, paste0(path, "Texas_County_Outlines.rds"))