@mailwoman/tiger 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/block-group.ts +151 -0
- package/class-code.ts +1026 -0
- package/constants.ts +252 -0
- package/county-subdivision.ts +154 -0
- package/county.ts +135 -0
- package/files.ts +251 -0
- package/functional-status.ts +64 -0
- package/geoid.ts +678 -0
- package/index.ts +18 -0
- package/legal-statistical-area.ts +222 -0
- package/out/block-group.d.ts +135 -0
- package/out/block-group.d.ts.map +1 -0
- package/out/block-group.js +7 -0
- package/out/block-group.js.map +1 -0
- package/out/class-code.d.ts +863 -0
- package/out/class-code.d.ts.map +1 -0
- package/out/class-code.js +864 -0
- package/out/class-code.js.map +1 -0
- package/out/constants.d.ts +220 -0
- package/out/constants.d.ts.map +1 -0
- package/out/constants.js +98 -0
- package/out/constants.js.map +1 -0
- package/out/county-subdivision.d.ts +139 -0
- package/out/county-subdivision.d.ts.map +1 -0
- package/out/county-subdivision.js +7 -0
- package/out/county-subdivision.js.map +1 -0
- package/out/county.d.ts +120 -0
- package/out/county.d.ts.map +1 -0
- package/out/county.js +9 -0
- package/out/county.js.map +1 -0
- package/out/files.d.ts +118 -0
- package/out/files.d.ts.map +1 -0
- package/out/files.js +142 -0
- package/out/files.js.map +1 -0
- package/out/functional-status.d.ts +64 -0
- package/out/functional-status.d.ts.map +1 -0
- package/out/functional-status.js +65 -0
- package/out/functional-status.js.map +1 -0
- package/out/geoid.d.ts +438 -0
- package/out/geoid.d.ts.map +1 -0
- package/out/geoid.js +255 -0
- package/out/geoid.js.map +1 -0
- package/out/index.d.ts +18 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +18 -0
- package/out/index.js.map +1 -0
- package/out/legal-statistical-area.d.ts +222 -0
- package/out/legal-statistical-area.d.ts.map +1 -0
- package/out/legal-statistical-area.js +223 -0
- package/out/legal-statistical-area.js.map +1 -0
- package/out/sdk/fetch.d.ts.map +1 -0
- package/out/sdk/fetch.js.map +1 -0
- package/out/sdk/index.d.ts +7 -0
- package/out/sdk/index.d.ts.map +1 -0
- package/out/sdk/index.js +7 -0
- package/out/sdk/index.js.map +1 -0
- package/out/sdk/redistricting.d.ts.map +1 -0
- package/out/sdk/redistricting.js.map +1 -0
- package/out/sdk/schema.d.ts.map +1 -0
- package/out/sdk/schema.js.map +1 -0
- package/out/sdk/state/TIGERTabulatedBlockEntity.d.ts +13 -0
- package/out/sdk/state/TIGERTabulatedBlockEntity.d.ts.map +1 -0
- package/out/sdk/state/TIGERTabulatedBlockEntity.js +22 -0
- package/out/sdk/state/TIGERTabulatedBlockEntity.js.map +1 -0
- package/out/sdk/state/TIGERTractEntity.d.ts +31 -0
- package/out/sdk/state/TIGERTractEntity.d.ts.map +1 -0
- package/out/sdk/state/TIGERTractEntity.js +7 -0
- package/out/sdk/state/TIGERTractEntity.js.map +1 -0
- package/out/sdk/state/block-operations.d.ts +36 -0
- package/out/sdk/state/block-operations.d.ts.map +1 -0
- package/out/sdk/state/block-operations.js +37 -0
- package/out/sdk/state/block-operations.js.map +1 -0
- package/out/sdk/state/index.d.ts +9 -0
- package/out/sdk/state/index.d.ts.map +1 -0
- package/out/sdk/state/index.js +9 -0
- package/out/sdk/state/index.js.map +1 -0
- package/out/state.d.ts +595 -0
- package/out/state.d.ts.map +1 -0
- package/out/state.js +384 -0
- package/out/state.js.map +1 -0
- package/out/tabulation-block.d.ts +43 -0
- package/out/tabulation-block.d.ts.map +1 -0
- package/out/tabulation-block.js +9 -0
- package/out/tabulation-block.js.map +1 -0
- package/out/tract.d.ts +36 -0
- package/out/tract.d.ts.map +1 -0
- package/out/tract.js +8 -0
- package/out/tract.js.map +1 -0
- package/out/tsconfig.tsbuildinfo +1 -0
- package/package.json +41 -0
- package/sdk/data/nation/index.json +14642 -0
- package/sdk/index.ts +7 -0
- package/sdk/initialize.sql +161 -0
- package/sdk/state/TIGERTabulatedBlockEntity.ts +25 -0
- package/sdk/state/TIGERTractEntity.ts +34 -0
- package/sdk/state/block-operations.ts +69 -0
- package/sdk/state/index.ts +9 -0
- package/state.ts +553 -0
- package/tabulation-block.ts +68 -0
- package/tract.ts +52 -0
- package/tsconfig.json +16 -0
- package/typedoc.json +5 -0
package/files.ts
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* TIGER Census data utilities.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { AdminLevel1Code } from "./state.js"
|
|
10
|
+
|
|
11
|
+
//#region Constants
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Census TIGER levels for geographic data.
|
|
15
|
+
*
|
|
16
|
+
* @category Census
|
|
17
|
+
*/
|
|
18
|
+
export enum TIGERLevel {
|
|
19
|
+
State = "us_state",
|
|
20
|
+
County = "county",
|
|
21
|
+
CountySubdivision = "cousub",
|
|
22
|
+
Tract = "tract",
|
|
23
|
+
BlockGroup = "bg",
|
|
24
|
+
Block = "tabblock20",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* File extension for TIGER data files.
|
|
29
|
+
*
|
|
30
|
+
* @category Census
|
|
31
|
+
*/
|
|
32
|
+
export enum TIGERFileExtension {
|
|
33
|
+
/**
|
|
34
|
+
* Feature geometry, i.e. the shape of the geographic area.
|
|
35
|
+
*/
|
|
36
|
+
Shape = ".shp",
|
|
37
|
+
/**
|
|
38
|
+
* Index of the feature geometry for quick access.
|
|
39
|
+
*/
|
|
40
|
+
Index = ".shx",
|
|
41
|
+
/**
|
|
42
|
+
* Tabular attribute metadata.
|
|
43
|
+
*/
|
|
44
|
+
Attributes = ".dbf",
|
|
45
|
+
/**
|
|
46
|
+
* Coordinate system information. Describes the projection of the geographic data.
|
|
47
|
+
*/
|
|
48
|
+
Projection = ".prj",
|
|
49
|
+
/**
|
|
50
|
+
* Federal Geographic Data Committee (FGDC) metadata.
|
|
51
|
+
*/
|
|
52
|
+
FGDCMetadata = ".shp.xml",
|
|
53
|
+
/**
|
|
54
|
+
* International Organization for Standardization (ISO 191) metadata.
|
|
55
|
+
*/
|
|
56
|
+
ISOMetadata = ".shp.iso.xml",
|
|
57
|
+
/**
|
|
58
|
+
* ISO 191 (entity and attribute) metadata.
|
|
59
|
+
*/
|
|
60
|
+
EntityAttributeMetadata = ".shp.ea.iso.xml",
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Compressed ZIP archive.
|
|
64
|
+
*/
|
|
65
|
+
Zip = ".zip",
|
|
66
|
+
|
|
67
|
+
None = "",
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Order of TIGER levels for processing, from largest to smallest.
|
|
72
|
+
*/
|
|
73
|
+
export const TIGERLevelOrder = [
|
|
74
|
+
TIGERLevel.State,
|
|
75
|
+
TIGERLevel.Tract,
|
|
76
|
+
TIGERLevel.CountySubdivision,
|
|
77
|
+
TIGERLevel.BlockGroup,
|
|
78
|
+
TIGERLevel.Block,
|
|
79
|
+
] as const satisfies TIGERLevel[]
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The current TIGER vintage.
|
|
83
|
+
*
|
|
84
|
+
* @category Census
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export const TIGERCurrentVintage = 2023
|
|
88
|
+
export type TIGERCurrentVintage = typeof TIGERCurrentVintage
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
|
|
92
|
+
//#region File Name Generation
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Type-helper for TIGER feature geometry file names.
|
|
96
|
+
*
|
|
97
|
+
* @category Census
|
|
98
|
+
*/
|
|
99
|
+
export type TIGERStateLevelFileName<
|
|
100
|
+
SFC extends AdminLevel1Code,
|
|
101
|
+
Level extends TIGERLevel,
|
|
102
|
+
FileExtension extends TIGERFileExtension,
|
|
103
|
+
Vintage extends number = TIGERCurrentVintage,
|
|
104
|
+
> = `tl_${Vintage}_${SFC}_${Level}${FileExtension}`
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Template function to generate a TIGER file name.
|
|
108
|
+
*/
|
|
109
|
+
export function TIGERStateLevelFileName<
|
|
110
|
+
SFC extends AdminLevel1Code,
|
|
111
|
+
Level extends TIGERLevel,
|
|
112
|
+
FileExtension extends TIGERFileExtension,
|
|
113
|
+
Vintage extends number = TIGERCurrentVintage,
|
|
114
|
+
>(stateFIPSCode: SFC, level: Level, fileExtension: FileExtension, vintage: Vintage = TIGERCurrentVintage as Vintage) {
|
|
115
|
+
const fileName = `tl_${vintage}_${stateFIPSCode}_${level}${fileExtension}` satisfies TIGERStateLevelFileName<
|
|
116
|
+
SFC,
|
|
117
|
+
Level,
|
|
118
|
+
FileExtension,
|
|
119
|
+
number
|
|
120
|
+
>
|
|
121
|
+
|
|
122
|
+
return fileName
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type TIGERStateLevelZIPPath<
|
|
126
|
+
SFC extends AdminLevel1Code,
|
|
127
|
+
Level extends TIGERLevel,
|
|
128
|
+
Vintage extends number = TIGERCurrentVintage,
|
|
129
|
+
> = `/geo/tiger/TIGER${Vintage}/${Uppercase<Level>}/${TIGERStateLevelFileName<SFC, Level, TIGERFileExtension.Zip, Vintage>}`
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Template function to generate a TIGER ZIP file path.
|
|
133
|
+
*/
|
|
134
|
+
export function TIGERStateLevelZIPPath<
|
|
135
|
+
SFC extends AdminLevel1Code,
|
|
136
|
+
Level extends TIGERLevel,
|
|
137
|
+
Vintage extends number = TIGERCurrentVintage,
|
|
138
|
+
>(stateFIPSCode: SFC, level: Level, vintage: Vintage = TIGERCurrentVintage as Vintage) {
|
|
139
|
+
const levelPath = level.toUpperCase() as Uppercase<Level>
|
|
140
|
+
const fileName = TIGERStateLevelFileName(stateFIPSCode, level, TIGERFileExtension.Zip, vintage)
|
|
141
|
+
const path = `/geo/tiger/TIGER${vintage}/${levelPath}/${fileName}` satisfies TIGERStateLevelZIPPath<
|
|
142
|
+
SFC,
|
|
143
|
+
Level,
|
|
144
|
+
Vintage
|
|
145
|
+
>
|
|
146
|
+
|
|
147
|
+
return path
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Template function to generate a TIGER ZIP file path.
|
|
152
|
+
*/
|
|
153
|
+
export function TIGERNationZIPPath<Vintage extends number = TIGERCurrentVintage>(
|
|
154
|
+
vintage: Vintage = TIGERCurrentVintage as Vintage
|
|
155
|
+
) {
|
|
156
|
+
const fileName = `tl_${vintage}_${TIGERLevel.State}${TIGERFileExtension.Zip}` as const
|
|
157
|
+
|
|
158
|
+
const path = `/geo/tiger/TIGER${vintage}/STATE/${fileName}` as const
|
|
159
|
+
// https://www2.census.gov/geo/tiger/TIGER2023/STATE/tl_2023_us_state.zip
|
|
160
|
+
|
|
161
|
+
return path
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
|
|
166
|
+
//#region Manifests
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* A TIGER manifest for a specific state at a specific level of detail.
|
|
170
|
+
*
|
|
171
|
+
* @category Census
|
|
172
|
+
*/
|
|
173
|
+
export interface TIGERLevelManifest<
|
|
174
|
+
SFC extends AdminLevel1Code,
|
|
175
|
+
Level extends TIGERLevel,
|
|
176
|
+
Vintage extends number = number,
|
|
177
|
+
> {
|
|
178
|
+
Shape: TIGERStateLevelFileName<SFC, Level, TIGERFileExtension.Shape, Vintage>
|
|
179
|
+
Index: TIGERStateLevelFileName<SFC, Level, TIGERFileExtension.Index, Vintage>
|
|
180
|
+
Attributes: TIGERStateLevelFileName<SFC, Level, TIGERFileExtension.Attributes, Vintage>
|
|
181
|
+
Projection: TIGERStateLevelFileName<SFC, Level, TIGERFileExtension.Projection, Vintage>
|
|
182
|
+
FGDCMetadata: TIGERStateLevelFileName<SFC, Level, TIGERFileExtension.FGDCMetadata, Vintage>
|
|
183
|
+
ISOMetadata: TIGERStateLevelFileName<SFC, Level, TIGERFileExtension.ISOMetadata, Vintage>
|
|
184
|
+
EntityAttributeMetadata: TIGERStateLevelFileName<SFC, Level, TIGERFileExtension.EntityAttributeMetadata, Vintage>
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function TIGERLevelManifest<
|
|
188
|
+
SFC extends AdminLevel1Code,
|
|
189
|
+
Level extends TIGERLevel,
|
|
190
|
+
Vintage extends number = TIGERCurrentVintage,
|
|
191
|
+
>(stateFIPSCode: SFC, level: Level, vintage?: Vintage) {
|
|
192
|
+
vintage ??= TIGERCurrentVintage as Vintage
|
|
193
|
+
|
|
194
|
+
const Shape = TIGERStateLevelFileName(stateFIPSCode, level, TIGERFileExtension.Shape, vintage)
|
|
195
|
+
const Index = TIGERStateLevelFileName(stateFIPSCode, level, TIGERFileExtension.Index, vintage)
|
|
196
|
+
const Attributes = TIGERStateLevelFileName(stateFIPSCode, level, TIGERFileExtension.Attributes, vintage)
|
|
197
|
+
const Projection = TIGERStateLevelFileName(stateFIPSCode, level, TIGERFileExtension.Projection, vintage)
|
|
198
|
+
const FGDCMetadata = TIGERStateLevelFileName(stateFIPSCode, level, TIGERFileExtension.FGDCMetadata, vintage)
|
|
199
|
+
const ISOMetadata = TIGERStateLevelFileName(stateFIPSCode, level, TIGERFileExtension.ISOMetadata, vintage)
|
|
200
|
+
const EntityAttributeMetadata = TIGERStateLevelFileName(
|
|
201
|
+
stateFIPSCode,
|
|
202
|
+
level,
|
|
203
|
+
TIGERFileExtension.EntityAttributeMetadata,
|
|
204
|
+
vintage
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
const manifest = {
|
|
208
|
+
Shape,
|
|
209
|
+
Index,
|
|
210
|
+
Attributes,
|
|
211
|
+
Projection,
|
|
212
|
+
FGDCMetadata,
|
|
213
|
+
ISOMetadata,
|
|
214
|
+
EntityAttributeMetadata,
|
|
215
|
+
} satisfies TIGERLevelManifest<SFC, Level, number>
|
|
216
|
+
|
|
217
|
+
return manifest as TIGERLevelManifest<SFC, Level, Vintage>
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* A full TIGER manifest for a specific state.
|
|
222
|
+
*/
|
|
223
|
+
export interface TIGERStateManifest<SFC extends AdminLevel1Code, Vintage extends number = TIGERCurrentVintage> {
|
|
224
|
+
Tract: TIGERLevelManifest<SFC, TIGERLevel.Tract, Vintage>
|
|
225
|
+
CountySubdivision: TIGERLevelManifest<SFC, TIGERLevel.CountySubdivision, Vintage>
|
|
226
|
+
BlockGroup: TIGERLevelManifest<SFC, TIGERLevel.BlockGroup, Vintage>
|
|
227
|
+
Block: TIGERLevelManifest<SFC, TIGERLevel.Block, Vintage>
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function TIGERStateManifest<SFC extends AdminLevel1Code, Vintage extends number = TIGERCurrentVintage>(
|
|
231
|
+
stateFIPSCode: SFC,
|
|
232
|
+
vintage?: Vintage
|
|
233
|
+
) {
|
|
234
|
+
vintage ??= TIGERCurrentVintage as Vintage
|
|
235
|
+
|
|
236
|
+
const Tract = TIGERLevelManifest(stateFIPSCode, TIGERLevel.Tract, vintage)
|
|
237
|
+
const CountySubdivision = TIGERLevelManifest(stateFIPSCode, TIGERLevel.CountySubdivision, vintage)
|
|
238
|
+
const BlockGroup = TIGERLevelManifest(stateFIPSCode, TIGERLevel.BlockGroup, vintage)
|
|
239
|
+
const Block = TIGERLevelManifest(stateFIPSCode, TIGERLevel.Block, vintage)
|
|
240
|
+
|
|
241
|
+
const manifest = {
|
|
242
|
+
Tract,
|
|
243
|
+
CountySubdivision,
|
|
244
|
+
BlockGroup,
|
|
245
|
+
Block,
|
|
246
|
+
} satisfies TIGERStateManifest<SFC, Vintage>
|
|
247
|
+
|
|
248
|
+
return manifest as TIGERStateManifest<SFC, Vintage>
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
//#endregion
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A code indicating the functional status of a governmental unit.
|
|
9
|
+
*
|
|
10
|
+
* @title TIGER Functional Status
|
|
11
|
+
*/
|
|
12
|
+
export enum TIGERFunctionalStatus {
|
|
13
|
+
/**
|
|
14
|
+
* Active government providing primary general-purpose functions. Active entity (federally
|
|
15
|
+
* recognized entities only).
|
|
16
|
+
*/
|
|
17
|
+
ActiveGovernment = "A",
|
|
18
|
+
/**
|
|
19
|
+
* Active government that is partially consolidated with another government but with separate
|
|
20
|
+
* officials providing primary general-purpose functions.
|
|
21
|
+
*/
|
|
22
|
+
PartiallyConsolidatedActiveGovernment = "B",
|
|
23
|
+
/**
|
|
24
|
+
* Active government consolidated with another government with a single set of officials.
|
|
25
|
+
*/
|
|
26
|
+
ActiveGovernmentConsolidated = "C",
|
|
27
|
+
/**
|
|
28
|
+
* Active government providing special-purpose functions.
|
|
29
|
+
*/
|
|
30
|
+
ActiveGovernmentSpecialPurpose = "E",
|
|
31
|
+
/**
|
|
32
|
+
* Fictitious entity created to fill the Census Bureau geographic hierarchy
|
|
33
|
+
*/
|
|
34
|
+
FictitiousEntity = "F",
|
|
35
|
+
/**
|
|
36
|
+
* Active government that is subordinate to another unit of government.
|
|
37
|
+
*/
|
|
38
|
+
SubordinateActiveGovernment = "G",
|
|
39
|
+
/**
|
|
40
|
+
* Inactive governmental unit that has the power to provide primary special-purpose functions.
|
|
41
|
+
*/
|
|
42
|
+
InActiveGovernmentalUnit = "I",
|
|
43
|
+
/**
|
|
44
|
+
* Inactive, nonfunctioning legal real property entity with potential quasi-legal administrative
|
|
45
|
+
* functions.
|
|
46
|
+
*/
|
|
47
|
+
InactiveNonFunctioningLegalRealPropertyEntity = "L",
|
|
48
|
+
/**
|
|
49
|
+
* Active legal real property entity with quasi-legal functions.
|
|
50
|
+
*/
|
|
51
|
+
ActiveLegalRealPropertyEntity = "M",
|
|
52
|
+
/**
|
|
53
|
+
* Non-functioning legal entity.
|
|
54
|
+
*/
|
|
55
|
+
NonFunctioningLegalEntity = "N",
|
|
56
|
+
/**
|
|
57
|
+
* Statistical entity.
|
|
58
|
+
*/
|
|
59
|
+
StatisticalEntity = "S",
|
|
60
|
+
/**
|
|
61
|
+
* Active state-recognized entity.
|
|
62
|
+
*/
|
|
63
|
+
ActiveStateRecognizedEntity = "T",
|
|
64
|
+
}
|