0

Using QGIS, how do I find county of an associated zipcode? I have zipcode for each point, however, I do not have a street address. I am hoping to aggregate my data to the county level using the zipcodes.

  • 2
    Zip codes are not typically exclusive to counties (at least not any place that I'm familiar with). I don't think this is going to work for you. If you think I'm wrong, get a layer of counties and a layer of zip codes for your area and see. – jbchurchill May 22 '15 at 13:23
  • Related question: gis.stackexchange.com/questions/146762 As jbchurchill points out, not all zips are contained within a single county. You'll want to be aware of this and make choices accordingly (ie that you're either going to put an entire zip into a county or you'll want to divide up the zip's values in some way, giving a portion to each county it falls within, and you'll need zip polygons for that). – Chris W May 23 '15 at 2:30
1

I would do a spatial join between your point data and US Counties.

If you do not have US Counties, you can download the 2014 Counties here.

Then, add both layers into your map.

Click Vector -> Data Management Tools -> Join attributes by location

Set the target vector layer to your points.

Set the join vector layer to your counties.

Choose to take attributes of first located feature.

Rename your output shapefile.

Select to keep all records (so you don't lose any records).

Click Ok.

Once complete, your point output will have the county information added to it.

Keep in mind:

  • The projections of your data
  • All fields from the counties will come over, but you can delete them once the process is completed
  • As reference, here is a tutorial doing a very similar process, except it chooses to aggregate a field rather than just joining the data
  • How would you get x and y's onto your postcodes layer? – HeikkiVesanto May 22 '15 at 13:27
  • @Vesanto - really that is a different question than what the OP asked, but you can reference this post. – evv_gis May 22 '15 at 13:33
  • 1
    Since zip and county boundaries aren't coincident, I think it would improve this answer if you address that. How will the spatial join handle a zip with two counties? Mention of the potential need for apportionment prior to aggregation might be important, since without it you skew results (and even with you're only estimating). – Chris W May 23 '15 at 2:27
  • 1
    The OP should clarify how the point data was created. If the point data is simply a centroid of the zip code area, then yes, adding information on how to handle more than one potential county should (and will) be added. – evv_gis May 23 '15 at 3:10
  • Good point. If they are randomly located within the zip code or just at the centroid (or either if they're just in tabular form) then there's some question over how to figure out which county they're in if even possible. Even without an address, if the points were in a specific location they could be geocoded to get one. Which wouldn't be necessary anyway, because at that point it's a simple point-in-polygon operation as your answer outlines and is discussed at a number of other questions here. – Chris W May 23 '15 at 21:47
0

Very simple solution to this. sign up here: https://www.mashape.com/vanitysoft/boundaries-io

then in your code: https://vanitysoft-boundaries-io-v1.p.mashape.com/reaperfire/rest/v1/public/boundary?and=true&county=Howard&includepostal=false&limit=30&state=MD

The results are GeoJson to easily integrate into repositories, or anything that takes GeoJson like googleMap... used http://geojsonlint.com/ to cut and paste my GeoJson Results from the API call above to display the below image...Hope this helps!

image Howard County in Marylandreturns below:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.