I guess you're using Godot 3.2.3 or older? There was a batching issue in these versions, which was fixed just a couple of week ago: https://github.com/godotengine/godot/pull/42119 . I compared polygon performance between 3.2.3 und 3.2.4 Beta 3 and immediately saw a performance increase. But yes, if you can decrease the number of nodes, this will also help regardless of the version you're using.
So I'd suggest the following changes:
1) Run your project in the latest version of Godot (currently 3.2.4 Beta 3).
2) Instead of thousands of Area2D, manually create just one in your scene tree ("ClickableMap")
3) In your ready function, add all CollisionShapes to this Area2D, and send all polygons to the VisualServer directly (without instancing Polygon2Ds any more):
for cell in cells:
var coll = CollisionPolygon2D.new()
var item = VisualServer.canvas_item_create()
VisualServer.canvas_item_add_polygon(item, cell, [Color(randf(), randf(), randf())])
4) Connect the input_event signal of ClickableMap and use the shape ID to check which region was clicked:
func _on_ClickableMap_input_event(_viewport, event, shape_idx):
if event is InputEventMouseButton and event.pressed:
if event.button_index == 1:
print ("Region #" + str(shape_idx) + " was selected.")
This should be enough to raise the performance back to reasonable framerates.