Tip: How to add geoCoordinates data

FYI, I’ve seen some questions come up recently regarding formatting geo coordinate data. They take a form like this, where they are nested under the property name.

So, in your collection (class) definition, you would have the property name, with datatype geoCoordinates. Then, you can add the data objects like this (e.g. Python):

import weaviate

client = weaviate.Client("http://localhost:8080")

data_obj = {
  "name": "Elsevier",
  "headquartersGeoLocation": {  # Your property name
    "latitude": 52.3932696,
    "longitude": 4.8374263
  }
}

data_uuid = client.data_object.create(
  data_obj,
  "Publication",  # Collection name
  uuid="df48b9f6-ba48-470c-bf6a-57657cb07390", # optional, if not provided, one is going to be generated
)

References:

1 Like

We’ve added new examples on how to filer with GeoCoordinates:

Here is a python example with the new Python client:

response = publications.query.fetch_objects(
    filters=(
        wvc.query.Filter
        .by_property("headquartersGeoLocation")
        .within_geo_range(
            coordinate=wvc.data.GeoCoordinate(
                latitude=52.39,
                longitude=4.84
            ),
            distance=1000  # In meters
        )
    )
)