scensus-utils 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -16,6 +16,7 @@ begin
16
16
  gem.add_dependency('GeoRuby', '>= 1.3.4')
17
17
  gem.add_dependency('json', '>= 1.2.0')
18
18
  gem.add_dependency('progressbar', '>= 0.9.0')
19
+ gem.add_dependency('proj4rb')
19
20
 
20
21
  end
21
22
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/data/README.txt ADDED
@@ -0,0 +1,51 @@
1
+ This is the directory where you should put your shapefiles.
2
+
3
+ US States:
4
+ http://www2.census.gov/geo/tiger/TIGER2008/tl_2008_us_state00.zip
5
+
6
+ US Counties:
7
+ http://www2.census.gov/geo/tiger/TIGER2008/tl_2008_us_county00.zip
8
+
9
+ US Tracts:
10
+ (Download separately for each state)
11
+
12
+
13
+ Each of these geometries (states, counties, and tracts) all go into the Places table.
14
+ There are some common fields, and we've added one: fip_id - this is a concatenation of
15
+ the various state, county and tract codes.
16
+
17
+ 25 Massachusetts
18
+ 25011 Essex County in MA (011 is the county fip_id)
19
+ 25011040500 Un-named tract 040500 in Essex County (011) in MA (25)
20
+
21
+ This allows us to use the fip code to ask for any states, counties or tracts, and then
22
+ specify if we want to view just that geometry, or any geometries that intersect/are contained
23
+ in that geometry.
24
+
25
+ The fields for the Places table are the union of all three shapefiles. Some of the columns are only
26
+ contained in one type of shapefile, so some may be null.
27
+
28
+ statefp00
29
+ countyfp00
30
+ tractce00
31
+ ctidfp00 # tract fip ID
32
+ cntyidfp00 # county fip ID
33
+ name00
34
+ namelsad00
35
+ lsad00 # states and counties only
36
+ funcstat00
37
+ classfp00 # counties only
38
+ mtfcc00
39
+ stusps00 # states only
40
+ ur00 # counties and states only
41
+
42
+ id # the primary key of this table
43
+ fp_id # fip code. for states, this is just statefp00. for counties, this is
44
+ # statefp00 + countyfp00. Tracts are statefp00 + countyfp00 + tractce00
45
+ the_geom
46
+ encoded_points
47
+ encoded_levels
48
+ encoded_num_levels
49
+ encoded_zoom_factor
50
+ created_at
51
+ updated_at
@@ -0,0 +1 @@
1
+ GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
@@ -0,0 +1,506 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <metadata>
3
+ <idinfo>
4
+ <citation>
5
+ <citeinfo>
6
+ <origin>U.S. Department of Commerce, U.S. Census Bureau, Geography Division</origin>
7
+ <pubdate>2009</pubdate>
8
+ <title>TIGER/Line Shapefile, 2009, 2000 state, Massachusetts, Census 2000 County and Equivalent State-based</title>
9
+ <edition>2009</edition>
10
+ <geoform>vector digital data</geoform>
11
+ <onlink>http://www.census.gov/geo/www/tiger</onlink>
12
+ </citeinfo>
13
+ </citation>
14
+ <descript>
15
+ <abstract>The TIGER/Line Shapefiles are an extract of selected geographic and cartographic information from the Census MAF/TIGER database. The Census MAF/TIGER database represents a seamless national file with no overlaps or gaps between parts. However, each TIGER/Line Shapefile is designed to stand alone as an independent data set or the shapefiles can be combined to cover the whole nation.</abstract>
16
+ <purpose>In order for others to use the information in the Census MAF/TIGER database in a geographic information system (GIS) or for other geographic applications, the Census Bureau releases to the public extracts of the database in the form of TIGER/Line Shapefiles.</purpose>
17
+ <Subject_Entity>Massachusetts(25)</Subject_Entity>
18
+ </descript>
19
+ <timeperd>
20
+ <timeinfo>
21
+ <rngdates>
22
+ <begdate>200901</begdate>
23
+ <enddate>200905</enddate>
24
+ </rngdates>
25
+ </timeinfo>
26
+ <current>Publication Date</current>
27
+ </timeperd>
28
+ <status>
29
+ <progress>Complete</progress>
30
+ <update>TIGER/Line Shapefiles are extracted from the Census MAF/TIGER database. No changes or updates will be made to this version of the TIGER/Line Shapefiles. Future releases of TIGER/Line Shapefiles will reflect updates made to the Census MAF/TIGER database.</update>
31
+ </status>
32
+ <spdom>
33
+ <bounding>
34
+ <westbc>-73.508142</westbc>
35
+ <eastbc>-69.858861</eastbc>
36
+ <northbc>42.88679</northbc>
37
+ <southbc>41.187053</southbc>
38
+ </bounding>
39
+ </spdom>
40
+ <keywords>
41
+ <theme>
42
+ <themekt>ISO 19115 Topic Categories</themekt>
43
+ <themekey>boundaries</themekey>
44
+ </theme>
45
+ <theme>
46
+ <themekt>None</themekt>
47
+
48
+ <themekey>State or equivalent entity</themekey>
49
+ <themekey>Polygon</themekey>
50
+ </theme>
51
+ <place>
52
+ <placekt>INCITS.38-200x (R2004),INCITS.31-200x (R2007),INCITS.454-200x,INCITS 455-200x,INCITS 446-2008</placekt>
53
+ <placekey>United States</placekey>
54
+ <placekey>U.S.</placekey>
55
+ <placekey>State or Equivalent Entity</placekey>
56
+ <placekey>Massachusetts</placekey>
57
+ <placekey>MA</placekey>
58
+ <placekey>25</placekey>
59
+ </place>
60
+ </keywords>
61
+ <accconst>None</accconst>
62
+ <useconst>The TIGER/Line Shapefile products are not copyrighted however TIGER/Line and Census TIGER are registered trademarks of the U.S. Census Bureau. These products are free to use in a product or publication, however acknowledgement must be given to the U.S. Census Bureau as the source.
63
+ The boundary information in the TIGER/Line Shapefiles are for statistical data collection and tabulation purposes only; their depiction and designation for statistical purposes does not constitute a determination of jurisdictional authority or rights of ownership or entitlement and they are not legal land descriptions.Coordinates in the TIGER/Line shapefiles have six implied decimal places, but the positional accuracy of these coordinates is not as great as the six decimal places suggest.</useconst>
64
+ <Title_13_Restrictions>Yes, the data are free from Title 13 restrictions</Title_13_Restrictions>
65
+ <ptcontac>
66
+ <cntinfo>
67
+ <cntorgp>
68
+ <cntorg>U.S. Department of Commerce, U.S. Census Bureau, Geography Division, Geographic Products Branch</cntorg>
69
+ </cntorgp>
70
+ <cntaddr>
71
+ <addrtype>Mailing address</addrtype>
72
+ <address>4600 Silver Hill Road, Stop 7400</address>
73
+ <city>Washington</city>
74
+ <state>DC</state>
75
+ <postal>20233-7400</postal>
76
+ <country>United States</country>
77
+ </cntaddr>
78
+ <cntvoice>301-763-1128</cntvoice>
79
+ <cntfax>301-763-4710</cntfax>
80
+ <cntemail>geo.tiger@census.gov</cntemail>
81
+ </cntinfo>
82
+ </ptcontac>
83
+ </idinfo>
84
+ <Data_Set_Character_Set>8859part1</Data_Set_Character_Set>
85
+ <Data_Set_Language>eng</Data_Set_Language>
86
+ <dataqual>
87
+ <attracc>
88
+ <attraccr>Accurate against Federal Information Processing Standards (FIPS), FIPS Publication 6-4, and FIPS-55 at the 100% level for the codes and base names. The remaining attribute information has been examined but has not been fully tested for accuracy.</attraccr>
89
+ </attracc>
90
+ <logic>The Census Bureau performed automated tests to ensure logical consistency and limits of shapefiles. Segments making up the outer and inner boundaries of a polygon tie end-to-end to completely enclose the area. All polygons are tested for closure.
91
+ The Census Bureau uses its internally developed geographic update system to enhance and modify spatial and attribute data in the Census MAF/TIGER database. Standard geographic codes, such as FIPS codes for states, counties, municipalities, county subdivisions, places, American Indian/Alaska Native/Native Hawaiian areas, and congressional districts are used when encoding spatial entities. The Census Bureau performed spatial data tests for logical consistency of the codes during the compilation of the original Census MAF/TIGER database files. Most of the codes for geographic entities except states, counties, urban areas, Core Based Statistical Areas (CBSAs), American Indian Areas (AIAs), and congressional districts were provided to the Census Bureau by the USGS, the agency responsible for maintaining FIPS 55. Feature attribute information has been examined but has not been fully tested for consistency.
92
+ For the TIGER/Line Shapefiles, the Point and Vector Object Count for the G-polygon SDTS Point and Vector Object Type reflects the number of records in the shapefile attribute table. For multi-polygon features, only one attribute record exists for each multi-polygon rather than one attribute record per individual G-polygon component of the multi-polygon feature. TIGER/Line Shapefile multi-polygons are an exception to the G-polygon object type classification. Therefore, when multi-polygons exist in a shapefile, the object count will be less than the actual number of G-polygons.</logic>
93
+ <complete>Data completeness of the TIGER/Line Shapefiles reflects the contents of the Census MAF/TIGER database at the time the TIGER/Line Shapefiles were created.</complete>
94
+ <lineage>
95
+ <srcinfo>
96
+ <srccite>
97
+ <citeinfo>
98
+ <origin>U.S. Department of Commerce, U.S. Census Bureau, Geography Division</origin>
99
+ <pubdate>Unpublished material</pubdate>
100
+ <title>Census MAF/TIGER database</title>
101
+ </citeinfo>
102
+ </srccite>
103
+ <typesrc>online</typesrc>
104
+ <srctime>
105
+ <timeinfo>
106
+ <rngdates>
107
+ <begdate>200901</begdate>
108
+ <enddate>200905</enddate>
109
+ </rngdates>
110
+ </timeinfo>
111
+ <srccurr>Publication Date</srccurr>
112
+ </srctime>
113
+ <srccitea>MAF/TIGER</srccitea>
114
+ <srccontr>The selected geographic and cartographic information (line segments) are derived from the U.S. Census Bureau&apos;s Master Address File Topologically Integrated Geographic Encoding and Referencing (MAF/TIGER) database.</srccontr>
115
+ </srcinfo>
116
+ <procstep>
117
+ <procdesc>TIGER/Line Shapefiles are extracted from the Census MAF/TIGER database by nation, state, county, and entity. Census MAF/TIGER data for the nation, state, county, and entity are then distributed among 58 shapefiles each containing attributes for line, polygon, or landmark geographic data. </procdesc>
118
+ <srcused>Census MAF/TIGER</srcused>
119
+ <procdate>2009</procdate>
120
+ </procstep>
121
+ </lineage>
122
+ </dataqual>
123
+ <spdoinfo>
124
+ <indspref>Federal Information Processing Standards (FIPS), ANSI, and feature names.</indspref>
125
+ <direct>Vector</direct>
126
+ <ptvctinf>
127
+ <sdtsterm>
128
+ <sdtstype>G-polygon</sdtstype>
129
+ <ptvctcnt>14</ptvctcnt>
130
+ </sdtsterm>
131
+ </ptvctinf>
132
+ </spdoinfo>
133
+ <spref>
134
+ <horizsys>
135
+ <geograph>
136
+ <latres>0.000458</latres>
137
+ <longres>0.000458</longres>
138
+ <geogunit>Decimal degrees</geogunit>
139
+ </geograph>
140
+ <geodetic>
141
+ <horizdn>North American Datum of 1983 in the 48 contiguous states, the District of Columbia, Alaska, Hawaii, Puerto Rico, the Virgin Islands of the United States, and the Pacific Island Areas.</horizdn>
142
+ <ellips>Geodetic Reference System 80</ellips>
143
+ <semiaxis>6378137</semiaxis>
144
+ <denflat>298257</denflat>
145
+ </geodetic>
146
+ </horizsys>
147
+ </spref>
148
+ <eainfo>
149
+ <detailed>
150
+ <enttyp>
151
+ <enttypl>COUNTY00.shp</enttypl>
152
+ <enttypd>Census 2000 County and Equivalent State-based entities</enttypd>
153
+ <enttypds>U.S. Census Bureau</enttypds>
154
+ </enttyp>
155
+ <attr>
156
+ <attrlabl>STATEFP00</attrlabl>
157
+ <attrdef>Census 2000 state Federal Information Processing Standards (FIPS) codes</attrdef>
158
+ <attrdefs>U.S. Census Bureau</attrdefs>
159
+ <attrdomv>
160
+ <codesetd>
161
+ <codesetn>INCITS.38-200x (R2004), Codes for the Identification of the States, the District of Columbia, Puerto Rico, and the Insular Areas of the United States (Formerly FIPS 5-2)</codesetn>
162
+ <codesets>U.S. Census Bureau</codesets>
163
+ </codesetd>
164
+ </attrdomv>
165
+ </attr>
166
+ <attr>
167
+ <attrlabl>COUNTYFP00</attrlabl>
168
+ <attrdef>Census 2000 county Federal Information Processing Standards (FIPS) code</attrdef>
169
+ <attrdefs>U.S. Census Bureau</attrdefs>
170
+ <attrdomv>
171
+ <codesetd>
172
+ <codesetn>INCITS.31-200x (R2007), Codes for the Identification of Counties and Equivalent areas of the United States, Puerto Rico, and the Insular Areas of the United States (Formerly FIPS 6-4)</codesetn>
173
+ <codesets>U.S. Census Bureau</codesets>
174
+ </codesetd>
175
+ </attrdomv>
176
+ </attr>
177
+ <attr>
178
+ <attrlabl>CNTYIDFP00</attrlabl>
179
+ <attrdef>Census 2000 county identifier; a concatenation of Census 2000 state Federal Information Processing Standards (FIPS) code and county FIPS code</attrdef>
180
+ <attrdefs>U.S. Census Bureau</attrdefs>
181
+ <attrdomv>
182
+ <codesetd>
183
+ <codesetn>INCITS.38-200x (R2004), Codes for the Identification of the States, the District of Columbia, Puerto Rico, and the Insular Areas of the United States (Formerly FIPS 5-2), INCITS.31-200x (R2007), Codes for the Identification of the Counties and Equivalent Areas of the United States, Puerto Rico, and the Insular Areas of the United States (Formerly FIPS 6-4)</codesetn>
184
+ <codesets>U.S. Census Bureau</codesets>
185
+ </codesetd>
186
+ </attrdomv>
187
+ </attr>
188
+ <attr>
189
+ <attrlabl>NAME00</attrlabl>
190
+ <attrdef>Census 2000 county name</attrdef>
191
+ <attrdefs>U.S. Census Bureau</attrdefs>
192
+ <attrdomv>
193
+ <codesetd>
194
+ <codesetn>INCITS.31-200x (R2007), Codes for the Identification of the Counties and Equivalent Areas of the United States, Puerto Rico, and the Insular Areas of the United States (Formerly FIPS 6-4)</codesetn>
195
+ <codesets>U.S. Census Bureau</codesets>
196
+ </codesetd>
197
+ </attrdomv>
198
+ </attr>
199
+ <attr>
200
+ <attrlabl>NAMELSAD00</attrlabl>
201
+ <attrdef>Census 2000 name and the translated legal/statistical area description code for county</attrdef>
202
+ <attrdefs>U.S. Census Bureau</attrdefs>
203
+ <attrdomv>
204
+ <codesetd>
205
+ <codesetn>INCITS.31-200x (R2007), Codes for the Identification of the Counties and Equivalent Areas of the United States, Puerto Rico, and the Insular Areas of the United States (Formerly FIPS 6-4) and the translated legal/statistical area description code for county that appears in LSAD00</codesetn>
206
+ <codesets>U.S. Census Bureau</codesets>
207
+ </codesetd>
208
+ </attrdomv>
209
+ </attr>
210
+ <attr>
211
+ <attrlabl>LSAD00</attrlabl>
212
+ <attrdef>Census 2000 legal/statistical area description code for county</attrdef>
213
+ <attrdefs>U.S. Census Bureau</attrdefs>
214
+ <attrdomv>
215
+ <edom>
216
+ <edomv>00</edomv>
217
+ <edomvd>Blank</edomvd>
218
+ <edomvds>U.S. Census Bureau</edomvds>
219
+ </edom>
220
+ <edom>
221
+ <edomv>03</edomv>
222
+ <edomvd>City and Borough</edomvd>
223
+ <edomvds>U.S. Census Bureau</edomvds>
224
+ </edom>
225
+ <edom>
226
+ <edomv>04</edomv>
227
+ <edomvd>Borough</edomvd>
228
+ <edomvds>U.S. Census Bureau</edomvds>
229
+ </edom>
230
+ <edom>
231
+ <edomv>05</edomv>
232
+ <edomvd>Census Area</edomvd>
233
+ <edomvds>U.S. Census Bureau</edomvds>
234
+ </edom>
235
+ <edom>
236
+ <edomv>06</edomv>
237
+ <edomvd>County</edomvd>
238
+ <edomvds>U.S. Census Bureau</edomvds>
239
+ </edom>
240
+ <edom>
241
+ <edomv>07</edomv>
242
+ <edomvd>District</edomvd>
243
+ <edomvds>U.S. Census Bureau</edomvds>
244
+ </edom>
245
+ <edom>
246
+ <edomv>10</edomv>
247
+ <edomvd>Island</edomvd>
248
+ <edomvds>U.S. Census Bureau</edomvds>
249
+ </edom>
250
+ <edom>
251
+ <edomv>12</edomv>
252
+ <edomvd>Municipality</edomvd>
253
+ <edomvds>U.S. Census Bureau</edomvds>
254
+ </edom>
255
+ <edom>
256
+ <edomv>13</edomv>
257
+ <edomvd>Municipio</edomvd>
258
+ <edomvds>U.S. Census Bureau</edomvds>
259
+ </edom>
260
+ <edom>
261
+ <edomv>15</edomv>
262
+ <edomvd>Parish</edomvd>
263
+ <edomvds>U.S. Census Bureau</edomvds>
264
+ </edom>
265
+ <edom>
266
+ <edomv>25</edomv>
267
+ <edomvd>city</edomvd>
268
+ <edomvds>U.S. Census Bureau</edomvds>
269
+ </edom>
270
+ </attrdomv>
271
+ </attr>
272
+ <attr>
273
+ <attrlabl>CLASSFP00</attrlabl>
274
+ <attrdef>Census 2000 Federal Information Processing Standards (FIPS) 55 class code</attrdef>
275
+ <attrdefs>U.S. Census Bureau</attrdefs>
276
+ <attrdomv>
277
+ <edom>
278
+ <edomv>C7</edomv>
279
+ <edomvd>An incorporated place that is independent of any county</edomvd>
280
+ <edomvds>U.S. Census Bureau</edomvds>
281
+ </edom>
282
+ <edom>
283
+ <edomv>H1</edomv>
284
+ <edomvd>An active county or equivalent feature</edomvd>
285
+ <edomvds>U.S. Census Bureau</edomvds>
286
+ </edom>
287
+ <edom>
288
+ <edomv>H4</edomv>
289
+ <edomvd>An inactive county or equivalent feature</edomvd>
290
+ <edomvds>U.S. Census Bureau</edomvds>
291
+ </edom>
292
+ <edom>
293
+ <edomv>H5</edomv>
294
+ <edomvd>A statistical county equivalent feature</edomvd>
295
+ <edomvds>U.S. Census Bureau</edomvds>
296
+ </edom>
297
+ <edom>
298
+ <edomv>H6</edomv>
299
+ <edomvd>A county that is coextensive with an incorporated place, part of an incorporated place, or a consolidated city and the governmental functions of the county are part of the municipal govenment</edomvd>
300
+ <edomvds>U.S. Census Bureau</edomvds>
301
+ </edom>
302
+ </attrdomv>
303
+ </attr>
304
+ <attr>
305
+ <attrlabl>MTFCC00</attrlabl>
306
+ <attrdef>MAF/TIGER feature class code</attrdef>
307
+ <attrdefs>U.S. Census Bureau</attrdefs>
308
+ <attrdomv>
309
+ <edom>
310
+ <edomv>G4020</edomv>
311
+ <edomvd>County or Equivalent Feature</edomvd>
312
+ <edomvds>U.S. Census Bureau</edomvds>
313
+ </edom>
314
+ </attrdomv>
315
+ </attr>
316
+ <attr>
317
+ <attrlabl>UR00</attrlabl>
318
+ <attrdef>Census 2000 urban/rural indicator</attrdef>
319
+ <attrdefs>U.S. Census Bureau</attrdefs>
320
+ <attrdomv>
321
+ <edom>
322
+ <edomv>M</edomv>
323
+ <edomvd>Mixed - part of the land area is classified as urban and part is classified as rural</edomvd>
324
+ <edomvds>U.S. Census Bureau</edomvds>
325
+ </edom>
326
+ <edom>
327
+ <edomv>N</edomv>
328
+ <edomvd>Not Applicable (water-only and international areas)</edomvd>
329
+ <edomvds>U.S. Census Bureau</edomvds>
330
+ </edom>
331
+ <edom>
332
+ <edomv>R</edomv>
333
+ <edomvd>Area is classified as rural</edomvd>
334
+ <edomvds>U.S. Census Bureau</edomvds>
335
+ </edom>
336
+ <edom>
337
+ <edomv>U</edomv>
338
+ <edomvd>Area is classified as urban</edomvd>
339
+ <edomvds>U.S. Census Bureau</edomvds>
340
+ </edom>
341
+ </attrdomv>
342
+ </attr>
343
+ <attr>
344
+ <attrlabl>FUNCSTAT00</attrlabl>
345
+ <attrdef>Census 2000 functional status</attrdef>
346
+ <attrdefs>U.S. Census Bureau</attrdefs>
347
+ <attrdomv>
348
+ <edom>
349
+ <edomv>A</edomv>
350
+ <edomvd>Active government providing primary general-purpose functions</edomvd>
351
+ <edomvds>U.S. Census Bureau</edomvds>
352
+ </edom>
353
+ <edom>
354
+ <edomv>B</edomv>
355
+ <edomvd>Active government that is partially consolidated with another government but with separate officials providing primary general-purpose functions</edomvd>
356
+ <edomvds>U.S. Census Bureau</edomvds>
357
+ </edom>
358
+ <edom>
359
+ <edomv>C</edomv>
360
+ <edomvd>Active government consolidated with another government with a single set of officials</edomvd>
361
+ <edomvds>U.S. Census Bureau</edomvds>
362
+ </edom>
363
+ <edom>
364
+ <edomv>F</edomv>
365
+ <edomvd>Fictitious entity created to fill the Census Bureau geographic hierarchy</edomvd>
366
+ <edomvds>U.S. Census Bureau</edomvds>
367
+ </edom>
368
+ <edom>
369
+ <edomv>G</edomv>
370
+ <edomvd>Active government that is subordinate to another unit of government</edomvd>
371
+ <edomvds>U.S. Census Bureau</edomvds>
372
+ </edom>
373
+ <edom>
374
+ <edomv>N</edomv>
375
+ <edomvd>Nonfunctioning legal entity</edomvd>
376
+ <edomvds>U.S. Census Bureau</edomvds>
377
+ </edom>
378
+ <edom>
379
+ <edomv>S</edomv>
380
+ <edomvd>Statistical entity</edomvd>
381
+ <edomvds>U.S. Census Bureau</edomvds>
382
+ </edom>
383
+ </attrdomv>
384
+ </attr>
385
+ <attr>
386
+ <attrlabl>ALAND00</attrlabl>
387
+ <attrdef>Census 2000 land area</attrdef>
388
+ <attrdefs>U.S. Census Bureau</attrdefs>
389
+ <attrdomv>
390
+ <edom>
391
+ <edomv>0 to 9,999,999,999,999</edomv>
392
+ <edomvd>Blank</edomvd>
393
+ <edomvds>U.S. Census Bureau</edomvds>
394
+ </edom>
395
+ </attrdomv>
396
+ </attr>
397
+ <attr>
398
+ <attrlabl>AWATER00</attrlabl>
399
+ <attrdef>Census 2000 water area</attrdef>
400
+ <attrdefs>U.S. Census Bureau</attrdefs>
401
+ <attrdomv>
402
+ <edom>
403
+ <edomv>0 to 9,999,999,999,999</edomv>
404
+ <edomvd>Blank</edomvd>
405
+ <edomvds>U.S. Census Bureau</edomvds>
406
+ </edom>
407
+ </attrdomv>
408
+ </attr>
409
+ <attr>
410
+ <attrlabl>INTPTLAT00</attrlabl>
411
+ <attrdef>Census 2000 latitude of the internal point</attrdef>
412
+ <attrdefs>U.S. Census Bureau</attrdefs>
413
+ <attrdomv>
414
+ <edom>
415
+ <edomv>00</edomv>
416
+ <edomvd>Blank</edomvd>
417
+ <edomvds>U.S. Census Bureau</edomvds>
418
+ </edom>
419
+ </attrdomv>
420
+ </attr>
421
+ <attr>
422
+ <attrlabl>INTPTLON00</attrlabl>
423
+ <attrdef>Census 2000 longitude of the internal point</attrdef>
424
+ <attrdefs>U.S. Census Bureau</attrdefs>
425
+ <attrdomv>
426
+ <edom>
427
+ <edomv>00</edomv>
428
+ <edomvd>Blank</edomvd>
429
+ <edomvds>U.S. Census Bureau</edomvds>
430
+ </edom>
431
+ </attrdomv>
432
+ </attr>
433
+ </detailed>
434
+ </eainfo>
435
+ <distinfo>
436
+ <distrib>
437
+ <cntinfo>
438
+ <cntorgp>
439
+ <cntorg>U.S. Department of Commerce, U.S. Census Bureau, Geography Division, Geographic Products Branch</cntorg>
440
+ </cntorgp>
441
+ <cntaddr>
442
+ <addrtype>Mailing address</addrtype>
443
+ <address>4600 Silver Hill Road, Stop 7400</address>
444
+ <city>Washington</city>
445
+ <state>DC</state>
446
+ <postal>20233-7400</postal>
447
+ <country>United States</country>
448
+ </cntaddr>
449
+ <cntvoice>301-763-1128</cntvoice>
450
+ <cntfax>301-763-4710</cntfax>
451
+ <cntemail>geo.tiger@census.gov</cntemail>
452
+ </cntinfo>
453
+ </distrib>
454
+ <distliab>No warranty, expressed or implied is made with regard to the accuracy of these data, and no liability is assumed by the U.S. Government in general or the U.S. Census Bureau in specific as to the spatial or attribute accuracy of the data. The act of distribution shall not constitute any such warranty and no responsibility is assumed by the U.S. government in the use of these files. The boundary information in the TIGER/Line Shapefiles is for statistical data collection and tabulation purposes only; their depiction and designation for statistical purposes do not constitute a determination of jurisdictional authority or rights of ownership or entitlement and they are not legal land descriptions.</distliab>
455
+ <stdorder>
456
+ <digform>
457
+ <digtinfo>
458
+ <formname>TGRSHP (compressed)</formname>
459
+ <filedec>PK-ZIP, version 1.93 A or higher</filedec>
460
+ </digtinfo>
461
+ <digtopt>
462
+ <onlinopt>
463
+ <computer>
464
+ <networka>
465
+ <networkr>http://www.census.gov/geo/www/tiger</networkr>
466
+ </networka>
467
+ </computer>
468
+ </onlinopt>
469
+ <offoptn>
470
+ <offmedia>DVD-ROM (Only if offered offline)</offmedia>
471
+ <recfmt>ISO 9660</recfmt>
472
+ </offoptn>
473
+ </digtopt>
474
+ </digform>
475
+ <fees>The online copy of the TIGER/Line files may be accessed without charge.</fees>
476
+ <ordering>To obtain more information about ordering TIGER/Line shapefiles visit http://www.census.gov/geo/www/tiger </ordering>
477
+ </stdorder>
478
+ <techpreq>The TIGER/Line shapefiles contain geographic data only and do not include display mapping software or statistical data. For information on how to use the TIGER/Line shapefile data with specific software package users shall contact the company that produced the software.</techpreq>
479
+ </distinfo>
480
+ <metainfo>
481
+ <metd>20090507</metd>
482
+ <metc>
483
+ <cntinfo>
484
+ <cntorgp>
485
+ <cntorg>U.S. Department of Commerce, U.S. Census Bureau, Geography Division, Geographic Products Branch</cntorg>
486
+ </cntorgp>
487
+ <cntaddr>
488
+ <addrtype>Mailing address</addrtype>
489
+ <address>4600 Silver Hill Road, Stop 7400</address>
490
+ <city>Washington</city>
491
+ <state>DC</state>
492
+ <postal>20233-7400</postal>
493
+ <country>United States</country>
494
+ </cntaddr>
495
+ <cntvoice>301-763-1128</cntvoice>
496
+ <cntfax>301-763-4710</cntfax>
497
+ <cntemail>geo.tiger@census.gov</cntemail>
498
+ </cntinfo>
499
+ </metc>
500
+ <metstdn>FGDC Content Standards for Digital Geospatial Metadata</metstdn>
501
+ <metstdv>FGDC-STD-001-1998</metstdv>
502
+ <Metadata_Character_Set>8859part1</Metadata_Character_Set>
503
+ <Metadata_File_Identifier>tl_2009_25_county00.shp.xml</Metadata_File_Identifier>
504
+ <Metadata_Language>eng</Metadata_Language>
505
+ </metainfo>
506
+ </metadata>
data/lib/scensus-utils.rb CHANGED
@@ -10,7 +10,6 @@
10
10
  #
11
11
  # Other examples:
12
12
  # scensus-utils -q bar.doc
13
- # scensus-utils --verbose foo.html
14
13
  #
15
14
  # == Usage
16
15
  # scensus-utils [options] shapefiles_to_convert.shp
@@ -22,8 +21,7 @@
22
21
  # -v, --version Display the version, then exit
23
22
  # -q, --quiet Output as little as possible, overrides verbose
24
23
  # -V, --verbose Verbose output
25
- #
26
- # -o, --output TODO: Output file
24
+ # -o, --output Name of file to output
27
25
  # -s, --[no-]simplify Whether to simplify the polygons before encoding them. Default: simplify
28
26
  #
29
27
  # == Author
@@ -37,11 +35,18 @@ require 'optparse'
37
35
  require 'rdoc/usage'
38
36
  require 'ostruct'
39
37
  require 'date'
38
+ require 'pp'
40
39
 
41
40
  require 'progressbar'
42
41
  require 'json'
43
42
  require 'gmap_polyline_encoder.rb'
44
- require "geo_ruby"
43
+ require 'zlib'
44
+ require 'tempfile'
45
+ require 'fileutils'
46
+
47
+ require 'proj4rb'
48
+
49
+ require 'geo_ruby'
45
50
  include GeoRuby::Shp4r
46
51
 
47
52
  class App
@@ -57,8 +62,8 @@ class App
57
62
  @options = OpenStruct.new
58
63
  @options.verbose = false
59
64
  @options.quiet = false
60
- @options.output = 'scensus-utils-output.js'
61
65
  @options.simplify_p = true
66
+ @options.output_file = 'output.js'
62
67
  end
63
68
 
64
69
  # Parse options, check arguments, then process the command
@@ -92,9 +97,10 @@ class App
92
97
  opts.on('-V', '--verbose') { @options.verbose = true }
93
98
  opts.on('-q', '--quiet') { @options.quiet = true }
94
99
 
95
- opts.on('-o', '--output FILE', "Output file") do |f|
96
- @options.output = f
100
+ opts.on('-o', '--output FILE', "Output file") do |f|
101
+ @options.output_file = f
97
102
  end
103
+
98
104
  opts.on('-s', '--[no-]simplify') do |simplify|
99
105
  @options.simplify_p = simplify
100
106
  end
@@ -144,25 +150,22 @@ class App
144
150
  puts "#{File.basename(__FILE__)} version #{VERSION}"
145
151
  end
146
152
 
147
- def process_command
153
+ def process_command
148
154
  # Loop over each shapefile specified on the command line
149
155
  # and process the shapes contained within
150
156
 
151
- output_file = File.new(@options.output, "w+")
152
-
153
- puts "Finding geo shapes in the following files:"
154
-
157
+ output_file = File.new(@options.output_file, "w+")
158
+
159
+ @all_polygons = Array.new
155
160
  ARGV.each do |a|
156
161
  Dir.glob(a) do |shp|
157
162
  shp_basename = File.basename(shp)
158
- if shp_basename =~ /(.*)\.shp$/
159
- #puts " #{a} ..."
160
-
161
- ShpFile.open(shp) do |shp|
163
+ if shp_basename =~ /(.*)\.shp$/
164
+ ShpFile.open(shp) do |shp|
162
165
  pbar = ProgressBar.new(File.basename(a), shp.record_count, STDOUT)
163
166
  pbar.format="%-14s %3d%% %s %s"
164
167
 
165
- shp.each do |shape|
168
+ shp.each do |shape|
166
169
  pbar.inc
167
170
  shape.data["STATEFP00"] ||= ""
168
171
  shape.data["COUNTYFP00"] ||= ""
@@ -170,43 +173,44 @@ class App
170
173
 
171
174
  # The FPID is useful for quickly narrowing down a search of the shapes
172
175
  shape.data["FPID"] = shape.data["STATEFP00"] + shape.data["COUNTYFP00"] + shape.data["TRACTCE00"]
173
-
174
- points_text = shape.geometry.text_representation
175
- # Since the text_representation looks like this:
176
- # ((-72.574763 42.579249,-72.574716 42.579381,-72.574707 42.579407))
177
- # we need to do some data massaging to get it into the encoding class as an array
178
-
179
- @geometry_points = Array.new
180
- # Remove all parantheses, split on the comma, then split on the space. reconstruct the array
181
- @point_pairs = points_text.gsub("(", "").gsub(")", "").split(",")
182
- @point_pairs.each do |p|
183
- # split the string into an array. push that array onto the data array
184
- @one_pair = p.split(" ")
185
- # Convert to floats
186
- @one_pair = @one_pair.map do |point|
187
- point.to_f
176
+
177
+ # Loop over each ring that makes up the polygon
178
+ # (mostly 1 polygon per shape, in this case)
179
+ @rings = Array.new
180
+ # shape.geometry.geomtries is an array of polygons
181
+ shape.geometry.geometries.each do |line_ring|
182
+ line_ring.each do |ring|
183
+ @this_ring = Array.new
184
+ ring.points.each do |p|
185
+ # p.x and p.y are the points for this polygon
186
+
187
+ # TODO: use proj4 to project these into utm
188
+
189
+ @this_ring.push([p.x, p.y])
190
+ end
191
+ @rings.push(@this_ring)
188
192
  end
189
-
190
- @geometry_points.push(@one_pair.reverse)
191
- end
192
-
193
- encoder = GMapPolylineEncoder.new()
194
- shape.data["POLYLINES"] = encoder.encode(@geometry_points)
195
-
196
- output_file.syswrite(shape.data.to_json)
197
- end
198
- end
199
- end
200
- end
201
- end
193
+ end # end rings
194
+
195
+ @all_polygons.push(@rings)
196
+ end # end each shape
197
+ end # end if shapefile
198
+ end # end shapefile open
199
+
200
+ #encoder = GMapPolylineEncoder.new()
201
+ #shape.data["POLYLINES"] = encoder.encode(@all_polygons)
202
+ output_file.syswrite(@all_polygons.to_json)
203
+
204
+ end # end Dir
205
+ end # end ARGV each
206
+
207
+ puts
202
208
  puts "Done processing all shapefiles that were found."
203
209
  end
204
210
  end
205
211
 
206
-
207
- # TODO - Add your Modules, Classes, etc
208
-
209
-
210
212
  # Create and run the application
211
213
  app = App.new(ARGV, STDIN)
212
214
  app.run
215
+
216
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scensus-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Wieczorek
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-25 00:00:00 -05:00
12
+ date: 2010-03-12 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -52,6 +52,16 @@ dependencies:
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.9.0
54
54
  version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: proj4rb
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
55
65
  description: The US Census can be hard to digest for mere mortals. Geographic data is hidden away in shapefiles, a format unsupported by the freely available mapping sites like Google Maps and OpenStreetMap. Map servers, like GeoServer and MapServer have support for shapefiles, but those solutions are often too much for smaller organizations to set up and maintain. Scensus is a project to bring simple mapping of US Census data to the rest of us. Scensus-utils is a set of ruby scripts and files necessary to transform the census data in use for the Scensus project. You do not need to install Scensus-utils to run Scensus, but they are provided to foster further collaboration on the techniques and tools used to map.
56
66
  email: tonyjw@gmail.com
57
67
  executables: []
@@ -68,6 +78,12 @@ files:
68
78
  - README.rdoc
69
79
  - Rakefile
70
80
  - VERSION
81
+ - data/README.txt
82
+ - data/shapefiles/tl_2009_25_county00/tl_2009_25_county00.dbf
83
+ - data/shapefiles/tl_2009_25_county00/tl_2009_25_county00.prj
84
+ - data/shapefiles/tl_2009_25_county00/tl_2009_25_county00.shp
85
+ - data/shapefiles/tl_2009_25_county00/tl_2009_25_county00.shp.xml
86
+ - data/shapefiles/tl_2009_25_county00/tl_2009_25_county00.shx
71
87
  - lib/gmap_polyline_encoder.rb
72
88
  - lib/scensus-utils.rb
73
89
  - test/helper.rb