Reading In-memory Geometry

Learn how to import geometries that have been created from scratch and are stored in memory.

Introduction

We've seen how to open files that are stored locally and how we can open them directly from the internet as well, without the need to store them locally. But it's sometimes useful to import data into GeoDataFrame objects that are already in the memory, either because they have been created from scratch or because they are the result of another spatial processing workflow.

In these scenarios, it is also possible to load these features directly onto GeoPandas. Let's take a look at two workarounds in these cases.

Creating geometries from scratch

For this example, let's create some geometries from scratch. We can do that by using a package called GeoJSON. It has a function called generate_random that creates random geometries with a given number of vertices inside a specified bounding box, like so:

Get hands-on with 1400+ tech skills courses.