X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/b062e7e7744d9f8f4a28d9c62197143d7352569d..2cb5e7b0cc7225daa81ca872449370727bbef07b:/utils/tigerAddressImport.py?ds=sidebyside diff --git a/utils/tigerAddressImport.py b/utils/tigerAddressImport.py index c0d83ceb..b1e2eb0c 100755 --- a/utils/tigerAddressImport.py +++ b/utils/tigerAddressImport.py @@ -35,9 +35,10 @@ except: import ogr import osr -# tiger_county_fips was generated from the following: -# wget http://www.census.gov/datamap/fipslist/AllSt.txt -# cat AllSt.txt | grep '^ [0-9]' | awk "{printf \"'%s' : '%s' ,\\n\", \$1, substr(\$0, 31)}" | > countyfips.py +# https://www.census.gov/geo/reference/codes/cou.html +# tiger_county_fips.json was generated from the following: +# wget https://www2.census.gov/geo/docs/reference/codes/files/national_county.txt +# cat national_county.txt | perl -F, -naE'($F[0] ne 'AS') && $F[3] =~ s/ ((city|City|County|District|Borough|City and Borough|Municipio|Municipality|Parish|Island|Census Area)(?:, |\Z))+//; say qq( "$F[1]$F[2]": "$F[3], $F[0]",)' json_fh = open(os.path.dirname(sys.argv[0]) + "/tiger_county_fips.json") county_fips_data = json.load(json_fh) @@ -161,9 +162,9 @@ def parse_shp_for_geom_and_tags( filename ): statefp = poFeature.GetField("STATEFP") countyfp = poFeature.GetField("COUNTYFP") if (statefp != None) and (countyfp != None): - county_name = county_fips_data[statefp + '' + countyfp] + county_name = county_fips_data.get(statefp + '' + countyfp) if county_name: - tags["tiger:county"] = county_name + tags["tiger:county"] = county_name.encode("utf-8") # tlid = poFeature.GetField("TLID") # if tlid != None: