# List of U.S. county codes?

**URL:** <https://forum.inaturalist.org/t/list-of-u-s-county-codes/50439>\
**Category:** General\
**Created:** [April 15, 2024, 2:32am UTC](https://forum.inaturalist.org/t/list-of-u-s-county-codes/50439 "2024-04-15T02:32:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![awharvey](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.inaturalist.org/awharvey/32/28871_2.png) [@awharvey](https://forum.inaturalist.org/u/awharvey)\
**Post date:** [April 15, 2024, 2:32am UTC](https://forum.inaturalist.org/t/list-of-u-s-county-codes/50439/1 "2024-04-15T02:32:21Z")

</div>

I’ve been using the API to extract some additional information for some 6000 records of an invasive plant across North America. Our project, for various reasons, has focused on county-level records. The API does, technically, include county info, in the place\_ids variable. But this information is coded (e.g., Alachua Cty., FL is 2511) and mixed in with an often impressive number of scaled place codes (e.g., `"place_ids": [1, 19, 339, 9853, 51894, 57106, 59613, 59649, 61551, 64422, 64423, 66741, 81418, 81775, 82256, 82257, 90754, 96685, 97394, 127683, 127684, 145691, 157671, 201280],`).

By any chance is there available somewhere accessible a list of U.S. counties with their corresponding iNaturalist code? Or at the least, are U.S. county codes bounded within a specific range? Any insights would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![jwidness](https://avatars.discourse-cdn.com/v4/letter/j/9d8465/32.png) [@jwidness](https://forum.inaturalist.org/u/jwidness)\
**Post date:** [April 15, 2024, 3:21am UTC](https://forum.inaturalist.org/t/list-of-u-s-county-codes/50439/2 "2024-04-15T03:21:02Z")

</div>

You can find all the place codes in [http://www.inaturalist.org/places/inaturalist-places.csv.zip](http://www.inaturalist.org/places/inaturalist-places.csv.zip)

You should get all the US county-level places by filtering for admin\_level 20 and ancestry starting with 97394/1/, but you might want to double check that.

---

<div class="post-metadata">

**Author:** ![zygy](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.inaturalist.org/zygy/32/1134_2.png) [@zygy](https://forum.inaturalist.org/u/zygy)\
**Post date:** [April 15, 2024, 4:14am UTC](https://forum.inaturalist.org/t/list-of-u-s-county-codes/50439/3 "2024-04-15T04:14:09Z")

</div>

Not sure if this helps, but you can get the county name for an observation using something like this (untested sloppy and probably outdated jQuery code):

```auto
var placeList = observation.place_ids.toString();
var iNatApi = 'https://api.inaturalist.org/v1/places/' + placeList;
var params = { 'admin_level': '20' };
$.getJSON( iNatApi, params )
	.done( function( data ) {
		if ( data.results[0] !== undefined && data.results[0].name !== undefined ) {
			return data.results[0].name;
		} else {
			return null;
		}
	} );

```

---

<div class="post-metadata">

**Author:** ![zygy](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.inaturalist.org/zygy/32/1134_2.png) [@zygy](https://forum.inaturalist.org/u/zygy)\
**Post date:** [April 15, 2024, 4:30am UTC](https://forum.inaturalist.org/t/list-of-u-s-county-codes/50439/4 "2024-04-15T04:30:13Z")

</div>

If my code above is confusing, you basically want to convert your example data into an API query like: [https://api.inaturalist.org/v1/places/1,19,339,9853,51894,57106,59613,59649,61551,64422,64423,66741,81418,81775,82256,82257,90754,96685,97394,127683,127684,145691,157671,201280?admin\_level=20](https://api.inaturalist.org/v1/places/1,19,339,9853,51894,57106,59613,59649,61551,64422,64423,66741,81418,81775,82256,82257,90754,96685,97394,127683,127684,145691,157671,201280?admin_level=20)  
and then retrieve results[0].name from the JSON that is returned. The admin\_level=20 filter will give you just the county, as jwidness mentions above.

---

<div class="post-metadata">

**Author:** ![pisum](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@pisum](https://forum.inaturalist.org/u/pisum)\
**Post date:** [April 15, 2024, 9:56am UTC](https://forum.inaturalist.org/t/list-of-u-s-county-codes/50439/5 "2024-04-15T09:56:38Z")

</div>

> [@zygy](#):
>
> probably outdated jQuery code

a thing that i mentioned in another recent thread by awharvey provides an example of how to do this in Python. see: [https://forum.inaturalist.org/t/is-it-possible-to-filter-by-observers-original-guess/50320/10](https://forum.inaturalist.org/t/is-it-possible-to-filter-by-observers-original-guess/50320/10).

---

<div class="post-metadata">

**Author:** ![awharvey](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.inaturalist.org/awharvey/32/28871_2.png) [@awharvey](https://forum.inaturalist.org/u/awharvey)\
**Post date:** [April 15, 2024, 2:04pm UTC](https://forum.inaturalist.org/t/list-of-u-s-county-codes/50439/6 "2024-04-15T14:04:33Z")

</div>

> [@jwidness](#):
>
> [http://www.inaturalist.org/places/inaturalist-places.csv.zip](http://www.inaturalist.org/places/inaturalist-places.csv.zip)

Excellent, that’s just what I needed. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/inaturalist/original/2X/7/7831452cf7f0d653ff1ffd34176334b7ef1b6a17.png) [@system](https://forum.inaturalist.org/u/system)\
**Post date:** [June 14, 2024, 2:05pm UTC](https://forum.inaturalist.org/t/list-of-u-s-county-codes/50439/7 "2024-06-14T14:05:02Z")

</div>

Closed on June 14, 2024, 2:05pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
