How to get kml boundaries for iNat places Wiki

Method 1: Easier, but only works for some places

From a place page, if you can see the “Edit place” link to the right just below the map, click on that. (It will not be available for all places.) When the next page loads, there will be a link under the map that says “Download KML”. That’s it!

Method 2: For places without “Edit place” link

Be aware that the kml available from the API is actually a simplified version of the place boundary. There is currently no way to get the precise version.

Find the id number of your place. One way is to go to the Identify search and enter the name of your place in the search box. The URL will now give you the place_id.

Go to https://api.inaturalist.org/v1/docs/#!/Places/get_places_id.
Enter the place_id in the Parameters section in the box that says “Provide multiple values in new lines (at least one required).”
Click the button that says “Try it out!”.
You want the information in the Response Body, but it’s not in quite the right format yet.
Open a text editor (e.g. Notepad++) and paste from the Response Body, starting at “geometry_geojson”.
Delete the _geojson so it just says geometry.
Add a curly brace and “type”: “Feature”, to the beginning of the file.
Correct the indents and delete the extra bracket and curly brace from the end of the file.
You should end up with something like this:

{
	"type": "Feature",
	"geometry": {
		"coordinates": [
		  [
			[
			  [
				32.6015,
				35.178200000000004
			  ],
			  [
				32.5867,
				35.2291
			  ],
			  [
				32.6281,
				35.243300000000005
			  ],
			  [
				32.6394,
				35.1837
			  ],
			  [
				32.6152,
				35.1634
			  ],
			  [
				32.6015,
				35.178200000000004
			  ]
			]
		  ]
		],
		"type": "MultiPolygon"
	}
}

Name this file with .json as the file extension, for example, my_place.json.
This is now a properly formatted geojson and can be read by any program that reads geojsons. There are online converter tools to change them into multiple different formats. QGIS also natively reads geojson files. To use QGIS to convert to kml, just drag the json file over to QGIS. Then right-click the layer name and choose Export->Save Features As…

6 Likes

I feel like you read my mind. :) Thanks for making this!

2 Likes

Very useful. Thanks! I just used method 2 on a place, and it worked very well. However, I imagine some folks without programming experience might get squeamish balancing curly braces.

1 Like