Generating GeoJSON with ChatGPT

I wrote a offhand tweet that picked up a (surprisingly) fair few likes about generating GeoJSON with OpenAI's (very in vogue) ChatGPT. I thought I would use this post to give an outline of my experiments with doing this and what the results were like. I started with something, simple but concrete for my first prompt:

Can you generate a square polygon in valid GeoJSON format?

The model came back with a valid GeoJSON Polygon:

{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-77.0366, 38.895],
[-77.0366, 38.855],
[-77.069, 38.855],
[-77.069, 38.895],
[-77.0366, 38.895]
]
]
},
"properties": {}
}

This looks like this when you plot it:

geojson

I then asked a follow up question to ChatGPT:

Where is that polygon located in the world?

ChatGPT correctly identified that the rectangle was in the Washington DC area and that it didn't seem to delineate any specific area:

The polygon defined in the previous answer is located in the Washington D.C. area, in the United States
Note that these coordinates are just an example and do not represent any specific location or feature.

I dug a bit deeper, having noticed a small error in terms of the question I had asked and the result I had received:

Is the polygon a square?

To which ChatGPT responded:

Yes, the polygon defined in the previous answer is a square [...]

Hmm - not exactly right but it wasn't a bad attempt. Let's try something a little bit more specific:

Can you give me a rectangle that covers London in GeoJSON format?

This was the resulting polygon.

{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-0.51, 51.28],
[-0.51, 51.2],
[0.0, 51.2],
[0.0, 51.28],
[-0.51, 51.28]
]
]
},
"properties": {}
}

it also provided the caveat that the polygon was just an estimate and was just an example of how to create a polygon of that nature. This is what the resulting polygon looks like:

london

This is obviously not quite right - but it does give the caveat that it is an estimate. There is an interesting question of why it thinks this is the correct boundary.

Let's try going back to the first polygon it returned - what if I ask it to provide a Feature Collection of GeoJSON Points within the Washington DC polygon?

inside washington

Wow - okay, that's pretty impressive. But was it a fluke? Let's try again with a Polygon I drew myself which ChatGPT didn't generate:

inside london

Not bad, but still room for improvement!

Published