Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help finding KML data for specific ZIP code

I'm making a heat map using New Jersey ZIP codes, but the geometry information I'm using is incorrect for two ZIP codes. Does anyone know where I can go to get the KML information for these two specific ZIP codes? I've seen a lot of posts here on what resources to use for KML data, but they are very advanced and I have no idea how to mine the databases that other people on the forum have linked to.

Specifically, I need the KML ZIP code data for ZIP codes 08559 and 08757. The following is the flawed KML data I have for these ZIP codes:

08559:

<Polygon><outerBoundaryIs><LinearRing><coordinates>-74.892528,40.414294,0.0 -74.967386,40.39857,0.0 -75.060361,40.420788,0.0 -75.064463,40.500774,0.0 -75.06583,40.517523,0.0 -75.068223,40.457705,0.0 -74.991314,40.481632,0.0 -74.88911,40.47001,0.0 -74.892528,40.414294,0.0</coordinates></LinearRing></outerBoundaryIs></Polygon>

08757:

<Polygon><outerBoundaryIs><LinearRing><coordinates>-74.190432,39.946002,0.0 -74.221537,39.932329,0.0 -74.322374,39.946002,0.0 -74.234185,40.008896,0.0 -74.26905,39.986678,0.0 -74.206839,39.952154,0.0 -74.19761,39.949762,0.0 -74.190432,39.946002,0.0</coordinates></LinearRing></outerBoundaryIs></Polygon>
like image 573
BenSeaver Avatar asked Aug 22 '26 06:08

BenSeaver


1 Answers

How to Create a Region Map with Multiple Zip Codes

  1. Download KML file containing all US zip codes from census.gov. The most current file on this site is: http://www2.census.gov/geo/tiger/GENZ2015/kml/cb_2015_us_zcta510_500k.zip. If this link is broken search Google for site:census.gov KML ZIP. Another option: https://www.filosophy.org/post/17/zipcodes_in_kml/


  1. Open this huge (175MB) text file in a plaintext editor and search for the zip code you want and copy the <Polygon> section. Here is the result when searching for >94117:

    <Placemark id="cb_2015_us_zcta510_500k.kml">
    <name>&lt;at&gt;&lt;openparen&gt;&lt;closeparen&gt;</name>
    <visibility>1</visibility>
    <description><![CDATA[<center><table><tr><th colspan='2' align='center'><em>Attributes</em></th></tr><tr bgcolor="#E3E3F3">
    <th>ZCTA5CE10</th>
    <td>94117</td>
    </tr><tr bgcolor="">
    <th>AFFGEOID10</th>
    <td>8600000US94117</td>
    </tr><tr bgcolor="#E3E3F3">
    <th>GEOID10</th>
    <td>94117</td>
    </tr><tr bgcolor="">
    <th>ALAND10</th>
    <td>4373059</td>
    </tr><tr bgcolor="#E3E3F3">
    <th>AWATER10</th>
    <td>1625</td>
    </tr></table></center>]]></description>
    <LookAt>
    <longitude>-102</longitude>
    <latitude>38.5</latitude>
    <range>7000000</range>
    <tilt>10</tilt>
    <heading>0</heading>
    </LookAt>
    <styleUrl>#KMLStyler</styleUrl>
    <ExtendedData>
    <SchemaData schemaUrl="#kml_schema_ft_cb_2015_us_zcta510_500k">
    <SimpleData name="ZCTA5CE10">94117</SimpleData>
    <SimpleData name="AFFGEOID10">8600000US94117</SimpleData>
    <SimpleData name="GEOID10">94117</SimpleData>
    <SimpleData name="ALAND10">4373059</SimpleData>
    <SimpleData name="AWATER10">1625</SimpleData>
    </SchemaData>
    </ExtendedData>
    <Polygon>
    <extrude>0</extrude>
    <tessellate>1</tessellate>
    <altitudeMode>clampToGround</altitudeMode>
    <outerBoundaryIs>
    <LinearRing>
    <coordinates>-122.477297,37.766069,0 -122.477379,37.765482,0 -122.458405,37.76616,0 -122.45779,37.766015,0 -122.457536,37.763566,0 -122.455999,37.763904,0 -122.456994,37.761842,0 -122.459173,37.761912,0 -122.455944,37.760239,0 -122.456603,37.759235,0 -122.454002,37.758785,0 -122.451817,37.759453,0 -122.447682,37.75919,0 -122.446783,37.761781,0 -122.445309,37.76188,0 -122.442915,37.763648,0 -122.443347,37.765333,0 -122.441242,37.765271,0 -122.4382,37.767159,0 -122.435624,37.767328,0 -122.435794,37.769058,0 -122.429128,37.769456,0 -122.428426,37.770452,0 -122.429178,37.774181,0 -122.429929,37.777909,0 -122.430115,37.778842,0 -122.444967,37.776958,0 -122.44478,37.776017,0 -122.446471,37.775802,0 -122.446846,37.777669,0 -122.453188,37.776853,0 -122.45281,37.774995,0 -122.463749,37.773624,0 -122.464611,37.77244,0 -122.459162,37.771314,0 -122.459901,37.770442,0 -122.464402,37.769669,0 -122.467004,37.768013,0 -122.469758,37.769209,0 -122.472245,37.76861,0 -122.473124,37.767116,0 -122.477297,37.766069,0 </coordinates>
    </LinearRing>
    </outerBoundaryIs>
    </Polygon>
    </Placemark>
    


  1. Create a clean KML file and move the <Polygon> to this file. Below is an example of a KML file (service-delivery-area.kml) with two zip code polygons. Google has a great KML Reference.

    <?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="http://www.opengis.net/kml/2.2">
      <Document>
        <name>Service Delivery Area</name>
        <open>0</open>
        <Placemark>
          <name>94117</name>
          <Polygon>
            <outerBoundaryIs>
              <LinearRing>
                <coordinates>
                  -122.477297,37.766069,0 -122.477379,37.765482,0 -122.458405,37.76616,0 -122.45779,37.766015,0 -122.457536,37.763566,0 -122.455999,37.763904,0 -122.456994,37.761842,0 -122.459173,37.761912,0 -122.455944,37.760239,0 -122.456603,37.759235,0 -122.454002,37.758785,0 -122.451817,37.759453,0 -122.447682,37.75919,0 -122.446783,37.761781,0 -122.445309,37.76188,0 -122.442915,37.763648,0 -122.443347,37.765333,0 -122.441242,37.765271,0 -122.4382,37.767159,0 -122.435624,37.767328,0 -122.435794,37.769058,0 -122.429128,37.769456,0 -122.428426,37.770452,0 -122.429178,37.774181,0 -122.429929,37.777909,0 -122.430115,37.778842,0 -122.444967,37.776958,0 -122.44478,37.776017,0 -122.446471,37.775802,0 -122.446846,37.777669,0 -122.453188,37.776853,0 -122.45281,37.774995,0 -122.463749,37.773624,0 -122.464611,37.77244,0 -122.459162,37.771314,0 -122.459901,37.770442,0 -122.464402,37.769669,0 -122.467004,37.768013,0 -122.469758,37.769209,0 -122.472245,37.76861,0 -122.473124,37.767116,0 -122.477297,37.766069,0
                </coordinates>
              </LinearRing>
            </outerBoundaryIs>
          </Polygon>
        </Placemark>
        <Placemark>
          <name>94102</name>
          <Polygon>
            <outerBoundaryIs>
              <LinearRing>
                <coordinates>
                  -122.429929,37.777909,0 -122.429178,37.774181,0 -122.428426,37.770452,0 -122.42822,37.769441,0 -122.426402,37.769596,0 -122.419334,37.77521,0 -122.419219,37.775316,0 -122.418704,37.775645,0 -122.404743,37.786778,0 -122.406399,37.786615,0 -122.406771,37.788499,0 -122.408595,37.789226,0 -122.411886,37.788808,0 -122.414807,37.78652,0 -122.414242,37.783724,0 -122.419182,37.783101,0 -122.420689,37.781955,0 -122.420906,37.782883,0 -122.422287,37.781752,0 -122.424108,37.782477,0 -122.427396,37.782057,0 -122.426829,37.779258,0 -122.429929,37.777909,0
                </coordinates>
              </LinearRing>
            </outerBoundaryIs>
          </Polygon>
        </Placemark>
      </Document>
    </kml>
    


  1. Go to https://www.google.com/mymaps/ and create a new map. Click "Add new layer", then click "Import", and upload your KML file. If the polygons are incorrect, you can edit the polygons on the map.


  1. Your map should have a result like this: https://www.google.com/maps/d/u/0/embed?mid=1zop5GMD1b2afmOvObQIi7YvF1d4
like image 134
Beau Smith Avatar answered Aug 27 '26 01:08

Beau Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!