TigerFetch.jl

Download TIGER/Line shapefiles from the US Census Bureau
Log | Files | Refs | README | LICENSE

commit d72848a3cf0ae7bf19bfe7ee16d22ba1ace3dad5
parent 4407b30b84018ef32e01671db4e1e762670a2c6d
Author: Erik Loualiche <eloualic@umn.edu>
Date:   Mon, 24 Feb 2025 09:31:26 -0600

clean doc

Diffstat:
MREADME.md | 5+++++
Mdocs/src/demo/simple_map.md | 11+++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md @@ -64,4 +64,9 @@ Look at the test suite (specifically `UnitTests/downloads.jl`) for now [![Lifecycle:Experimental](https://img.shields.io/badge/Lifecycle-Experimental-339999)](https://github.com/eloualiche/Prototypes.jl/actions/workflows/CI.yml) [![codecov](https://codecov.io/gh/eloualiche/TigerFetch.jl/graph/badge.svg?token=OZRTOQU9H6)](https://codecov.io/gh/eloualiche/TigerFetch.jl) +[![][docs-latest-img]][docs-latest-url] + + +[docs-latest-img]: https://img.shields.io/badge/docs-latest-blue.svg +[docs-latest-url]: https://eloualiche.github.io/TigerFetch.jl/ diff --git a/docs/src/demo/simple_map.md b/docs/src/demo/simple_map.md @@ -5,6 +5,7 @@ import Pkg; Pkg.add(["CairoMakie", "DataFrames", "DataFramesMeta"]) Pkg.add(["GADM", "GeoMakie", "GeometryOps", "GeoJSON", "Shapefile", "ZipFile"]); +nothing; #hide ``` You will need a bunch of libraries to plot these; maybe setup a temporary environment, because it is not fun waiting for Makie to recompile at every startup. @@ -13,6 +14,7 @@ using CairoMakie, DataFrames, DataFramesMeta using GADM, GeoMakie, GeometryOps, GeoJSON, Shapefile, ZipFile using TigerFetch tmp_dir = mktempdir(); map_dir = joinpath(tmp_dir, "map"); +nothing; #hide ``` ## Plotting county subdivisions @@ -21,12 +23,14 @@ We are downloading the county shapefiles (which is a national file), subsets it ```@example simplemap; tigerdownload("county"; output=map_dir) ; isfile(joinpath(map_dir, "tl_2024_us_county.zip")) +nothing; #hide ``` First, we process the file which is national to only keep counties in the state ```@example simplemap; df_shp_cty = Shapefile.Table(joinpath(map_dir, "tl_2024_us_county.zip")) |> DataFrame; @rsubset!(df_shp_cty, :STATEFP=="27"); +nothing; #hide ``` ```@example simplemap; @@ -47,6 +51,7 @@ save("p1.svg", fig); nothing # hide ## Addings water areas and roads +### Roads Roads are at the state level and water areas at the county level, so this will complete the example. From simple to more complicated we start with primary and secondary roads @@ -59,11 +64,12 @@ save("p2.svg", fig); nothing # hide ![](p2.svg) - +### Water And the water areas; we download them in a separate directory because there is one file per county: ```@example simplemap; mkpath(joinpath(map_dir, "MN")); tigerdownload("areawater"; state="MN", output=joinpath(map_dir, "MN")); +nothing; #hide ``` Then we read all of the downloaded shapefiles in the dictionary and keep only the subset of the largest lakes or rivers: @@ -72,13 +78,14 @@ df_shp_water = [ DataFrame(Shapefile.Table(joinpath(map_dir, "MN", f))) for f in readdir(joinpath(map_dir, "MN")) ]; df_shp_water = reduce(vcat, df_shp_water, cols=:union); @rsubset!(df_shp_water, :AWATER > 1_000_000); # only keep larger water +nothing; #hide ``` And now the plot: ```@example simplemap poly!(ga, df_shp_water.geometry; color=RGBf(170/255, 218/255, 255/255), - strokewidth=0.5, strokecolor=RGBf(144/255, 202/255, 249/255)); + strokewidth=0.25, strokecolor=RGBf(144/255, 202/255, 249/255)); save("p3.svg", fig); nothing # hide ``` ![](p3.svg)