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:
This looks like this when you plot it:
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.
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:
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?
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:
Not bad, but still room for improvement!