-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue performing geometry operation in GeoJSON file "Error: Referenced column "geometry" not found in FROM clause" #487
Comments
Hello!
|
Below is the code I used.
Thank you for your kind time. ` geojson_urls = [ con = duckdb.connect() con.execute("INSTALL spatial;") for index, geojson_url in enumerate(geojson_urls):
try:
except Exception as e: con.close()` |
Geometry is the name of the type not the column. The geometry column you get from ST_Read is called "geom", not "geometry" |
Thank you for your reply. I have issue using that url of GeoJSON. I have downloaded two GeoJSON files for a country and tried to do the same operations. It works and creates output. Columns in GeoJSON_data1: [('OBJECTID', 'INTEGER', 'YES', None, None, None), ('FCsubtype', 'INTEGER', 'YES', None, None, None), ('geom', 'GEOMETRY', 'YES', None, None, None)] `import duckdb Connect to DuckDBconn = duckdb.connect() Install and load the spatial extensionconn.execute("INSTALL spatial;") Load the first GeoJSON fileconn.execute(""" Load the second GeoJSON fileconn.execute(""" Check the column names in geo_data1columns_geo_data1 = conn.execute("DESCRIBE geo_data1").fetchall() Check the column names in geo_data2columns_geo_data2 = conn.execute("DESCRIBE geo_data2").fetchall() Example of performing a geometry operation: calculating the area of geometries in the second GeoJSONarea_result = conn.execute(""" Print the area resultsprint("Areas of geometries in the second GeoJSON file:") Example of a spatial join or union between the two datasetsunion_result = conn.execute(""" Create a new table for the union resultsconn.execute(""" Export the union results to a CSV fileoutput_directory = 'M:\R\DuckDb\union_results.csv' Close the connectionconn.close() print(f"Union results exported to {output_directory}") |
Hi,
I am exploring Duckdb to work with spatial files.
I am trying to import GeoJSON files and perform ST_UNION. I can read the files without any issue, but when performing ST_UNION operation, it result in the following error:
An error occurred while performing ST_UNION: Binder Error: Referenced column "geometry" not found in FROM clause!
Candidate bindings: "geo_data_0.geom", "geo_data_0.Reference_Geography", "geo_data_0.ObjectId"
LINE 5: SELECT geometry FROM geo_data_0
FYI: Somebody raised similar error a year ago. However, I have no idea whether it is updated or not. Please kindly share your comments
The text was updated successfully, but these errors were encountered: