Questions tagged [fiona]
Fiona is OGR's new, neat, Pythonic API
304
questions
0
votes
0
answers
23
views
Fiona Throws Error Null layer: ''
I have a file Mapp.kml (1 of 5). I am trying to read this file into Python through Fiona.
I keep getting an error
ValueError: Null layer: ''
Things I have tried:
polygon_1 = gpd.read_file('../MAPP....
1
vote
1
answer
108
views
Validate GeoJSON geometries using geojson Python package via Fiona
I have an application that allows users to submit a shapefile or GeoJSON file. I would like to use Python to validate the files and geometries within them to make sure I process valid geoms. Im having ...
0
votes
1
answer
64
views
how to install fiona on a newly generated github codespace?
This question as been asked multiple times here and on SO but it seems anything related to GDAL in the python realm requires special care on any new environment. So here is the Github codespace one.
I ...
0
votes
2
answers
86
views
Determining minx/miny/maxx/maxy for shape from polygon in GeoJSON file
I have implemented the following code to search a GeoJSON file for a point (not asking for a code review or critique):
#!/usr/local/bin/python3.11
import os
import sys
import fiona
import shapely
def ...
2
votes
1
answer
79
views
Updating metadata in geodatabase using fiona
I am trying to update the metadata on an already written .gdb with n layers. I would like to add the same metadata to each layer. When I read in the file and update the metadata dictionary, the added ...
0
votes
1
answer
68
views
Trouble loading fiona
I'm having trouble loading fiona. I am able to import/run GDAL and GeoPandas with no issues but when I try loading fiona, I get an error message (please see below). I have python (3.9.11) through ...
1
vote
1
answer
51
views
Does geopandas handle shapefiles (in lat/lon) that straddle the anti-meridian properly?
I have been looking for a way to check if a point lies within a shapefile. i had some code that worked for the most part (using shapely and fiona) but my understanding is that it will exhibit ...
0
votes
0
answers
69
views
Working with NHDPlus data in GDB file format using GeoPandas
I am trying to work with the NHDPlus High Resolution dataset from the USGS. Looking at the documentation, there should be all sorts of data table available as well as mapping layers but the only thing ...
0
votes
1
answer
562
views
Limiting Voronoi polygons from shapely.voronoi_polygons to a shape with extend_to
I'm trying to get some voronoi polygons from a set of coordinates distributed within a country, I don't need said polygons to extend out of the country, I tried using extend_to from voronoi_polygons ...
0
votes
0
answers
209
views
Comparing two GeoDataFrames that are written using different drivers
I'm trying to write one of the GeoDataFrames available with the GeoPandas package to a File GeoDataBase, read this back into memory, and then measure equality across these two GeoDataFrames. For some ...
0
votes
0
answers
41
views
Using the correct (?) schema gives an error as with the wrong one with Fiona
Created a shapefile with a specific schema. Attempting to use the same schema to append new polygon results in "ValueError: Record does not match collection schema" error. What could be the ...
0
votes
0
answers
513
views
GeoPandas fails silently when reading GeoJSONs
I have a file example.geojson. This file has 68 features (jq '.features | length' example.geojson returns 68).
If I try to load this file to a GeoPandas dataframe (gpd.read_file docs), I can choose ...
0
votes
0
answers
122
views
Generate points inside polygons in Python
I have one raster image and one vector field. I cut the raster image according to the vector area. I want to get the coordinates of each pixel of the cut image, but I couldn't. While the expected ...
1
vote
1
answer
919
views
Converting contours in an image to lines in shapefile using Python
I have processed a screenshot from Google Maps using OpenCV and identified some contours for the red road sections, and I want to project these contours to a shapefile. I have searched but couldn't ...
0
votes
1
answer
297
views
GeoPandas - can't write to file because field names are tuples (AttributeError)
I have created a new shapefile by dissolving and computing centroids from an existing shapefile. I have also aggregated values of the existing shapefile to use in the new shapefile. However, when I ...
0
votes
1
answer
149
views
Why do we need to specify a format driver with fiona?
What are format drivers for?
For example why is this necessary:
with fiona.open(save_file, "w", driver="ESRI Shapefile", schema=schema) as c:
Shouldn't it just be able to ...
0
votes
0
answers
60
views
Cannot read SHP polygon using Geopandas [duplicate]
I am trying to read ESRI SHP Polygon using geopandas:
polygon=gpd.read_file(r'Path.shp', encoding='utf-8', driver='ESRI Shapefile')
But I am getting this error:
NotImplementedError: A polygon does ...
1
vote
0
answers
24
views
Creating branched linestring [closed]
I have a shapefile where a cable consists of multiple parts. In the example below the highlighted cable consists of three parts. I have exported the attribute table and am trying to write a Python ...
2
votes
1
answer
2k
views
Trying to convert GeoPandas Dataframe with date to ESRI Shapefile
Created a GeoPandas dataframe from an excel sheet. The schema for the dataframe is:
{'geometry': 'Point',
'properties': OrderedDict([
...
('DISTID', 'int'),
('...
2
votes
1
answer
414
views
Finding distance between points using Python
I have a shapefile containing 10 test points like so:
The spatial reference is 2157 - Irish Transverse Mercator
I am wanting to find the distance between each point in Python. Ideally, something like ...
5
votes
1
answer
518
views
Read xml with CurvePolygon with Geopandas / Fiona
I am trying to use the Dutch BGT Api via https://api.pdok.nl/lv/bgt/download/v1_0/ui/ with the following code:
# Native
import requests
from requests.structures import CaseInsensitiveDict
import json
...
1
vote
0
answers
43
views
Calculation of the greatest fall in the river [closed]
I have a task to write a Python program using the 'gdal', 'geopandas', 'reasterio' and 'fiona' libraries. This program is to calculate the greatest fall in the river (height difference between the ...
5
votes
2
answers
3k
views
DriverError when reading GeoPackage with geopandas
I develop an import system that supports popular geoformats.
Sometimes I get a DriverError reading GeoPackage files with geopandas, but at times it works well.
My code is simple:
gdf = gpd.read_file(...
1
vote
1
answer
708
views
How to get all records if WFS output limited to 1000?
I use WFS quite a lot to collect my data with the script below. It works most of the time, but I notice that some of the WFS-services I come across have a limited output, as only 1000 records are ...
1
vote
1
answer
952
views
Measure distance between points in python
I am trying to determine a rough distance between points in my shapefile.
The shapefile I am working with has 28 million points in the structure x y z.
I am hoping to find the most common distance ...
1
vote
0
answers
2k
views
Import Errors: fiona and gdal
I can neither import fiona nor gdal.
I installed the following Python version:
Python 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)]
Furthermore I installed the ...
2
votes
0
answers
275
views
Can GDAL read/write Geopackage on RAM instead of disk?
I am working on a Python project that makes extensive use of GDAL's Geopackage vector and raster drivers. Since geopackage is essentially SQLite, I also use the Python SQLite library to do lots of ...
1
vote
2
answers
4k
views
Python error handling opening a shapefile with fiona
I've written a python script where I read a bunch of files trying to catch various errors (FileNotFound, Import), for example
try:
df = pd.read_excel(os.path.join(path_to_data, fname_data))
except ...
0
votes
1
answer
381
views
Clip data while reading file into Python with GeoPandas
Geopandas is able to read in only part of a file using:
roi= geopandas.GeoDataFrame(geometry)
indexed_data = geopandas.read_file("path-to-file", mask=roi)
or
geopandas.read_file("path-...
0
votes
1
answer
2k
views
Specific WFS error - Fiona: fiona.errors.DriverError: '/vsimem/4ec3f86c094340cc8704fe5b9aa0f517
I am trying to receive some data through several WFS servers. While two work with my code, one gives an error. I don't have enough experience with WFS to see how this one is different from the others.
...
3
votes
1
answer
3k
views
Problem exporting geodataframe to Esri shapefile having datetime field using Geopandas
I had a geodataframe having 4 columns (viz. name, time, description, geometry fiels). I am trying to export the geodataframe to ESRI Shapefile but it is throwing following error:
DriverSupportError: ...
1
vote
2
answers
2k
views
Error when viewing GeoDataFrame in GeoPandas: "OSError: exception: access violation reading 0x0000000000000000"
When running the following script
import fiona
import geopandas as gpd
data = gpd.read_file(r"C:\data.shp")
data.head()
I receive the following error
Access violation - no RTTI data!
...
0
votes
0
answers
134
views
Can't install Fiona in OSGeo4W Shell on Windows 10
When trying to install "Fiona‑1.8.20‑cp39‑cp39‑win_amd64.whl" in the OSGeo4W Shell I get the following errors:
extensions/gdal_wrap.cpp(3198): fatal error C1083: Datei (Include) kann nicht ...
1
vote
1
answer
439
views
Why is fiona not writing these records?
I'm running through a UTM grid in geojson format with fiona, attempting to add/populate a field based on other field values and then write out to a new file. It appears to successfully build the ...
0
votes
1
answer
161
views
When using Fiona, DBF missing headers when no records provided
I'm creating a Esri Shapefile using Fiona. If I don't add any records, the dbf created by Fiona does not include the headers defined by the schema. My customers claim that results in an invalid ...
0
votes
0
answers
248
views
Fiona schema property name length
Is it possible to increase property name length in schema?
If I define schema like this:
my_schema = { 'geometry': 'Point',
'properties': {'Here is very long property name': 'float:12.3'}
And in ...
3
votes
1
answer
2k
views
Opening DGN using Python
I'm trying to open a DGN file with Python.
I've tried with OGR:
driver = ogr.GetDriverByName("DGN")
file = driver.Open("C:\path_to_dgn\example.dgn")
which returns a NoneType ...
4
votes
1
answer
877
views
Including metadata in GeoPackage file written using GeoPandas/Fiona
I have a Geopandas GeoDataFrame with a couple of categorical columns that I want to write to a GeoPackage file. GeoPandas/Fiona/GeoPackage does not support categorical columns directly, so I'm ...
5
votes
2
answers
4k
views
Listing every layer in Geopackage using Fiona
I loaded a GeoPackage into Python and I can't figure out how to list all the layers in the file. How do I do that?
Input: GeoPackage loaded into Python.
Desired output: A list of the layers in the ...
4
votes
1
answer
1k
views
Writing properties corresponding to a given schema within the GeoDataFrame.to_file() method?
I currently have the following code to write a multipolygon Shapely feature to a GeoPackage:
import fiona
myschema = {'geometry': 'MultiPolygon', 'properties': {'id': 'int'}}
with fiona.open(
'/...
1
vote
0
answers
803
views
Pyinstaller .EXE AttributeError: partially initialized module 'fiona' has no attribute '_loading' (most likely due to a circular import)
I am trying to create a geospatial Python GUI app using PyQT5, Geopandas, OSMnX, and Folium. I am converting the app into an .EXE file using pyinstaller. Previously, I was successfully able to create ...
2
votes
1
answer
40
views
A raster clipping script does not produce output
I am using the following code to first divide a vector layer to many polygons and after that use them for clipping parts of a raster layer. It successfully split the vector layer to many polygons, but ...
3
votes
2
answers
347
views
Raster clipping from many polygons: 'error: NoneType' object is not subscriptable
I am using the following code to first divide a vector layer to many polygons and after that use them to clipping parts of a raster layer. The Name attribute in the vector data has a text data type. I ...
3
votes
0
answers
406
views
Split Raster into Tiles - Set Extent
I am using this questions solution to split a raster I have into 1500x1500 tiles. The code works. I have recently been trying to figure out how to set the starting and ending points of the raster ...
2
votes
1
answer
376
views
GDAL extracted EPSG not compatible with Fiona
I am creating Shapefiles from features extracted from JP2 images in python. My current method of creating Shapefiles by extracting the EPSG from the source image with GDAL and using Fiona is as below ...
0
votes
0
answers
886
views
Fiona Saving Gives DriverIOError
I have a script that I used before to clip polygons. I modified it a touch to use in another place, but am running into a fiona.errors.DriverIOError. As far as I can tell, all the code is working ...
1
vote
1
answer
2k
views
Setting CRS with EPSG code when writting shapefile with Fiona
How to set the CRS when writing an ESRI Shapefile using Fiona on a modern Python version (>3.x)?
Why "modern"? Because Python 2 is now deprecated and this user asked a similar question ...
3
votes
1
answer
687
views
Dissolving polygons based on polygon attribute values in Python
I have a shapefile, with multiple features inside. I am trying to dissolve the nearby/adjacent features based on the shapefile particular attribute value (gridcode), but the difference shouldn't be ...
2
votes
0
answers
772
views
Filtering records in GeoPackage file by numeric/text fields using GeoPandas/Fiona
I have a GPKG file of 46M records and 6.5GB filesize, and need to open about 300 records, where fieldX = Y (Y may change). Opening the entire file would cause memory overflow, while processing the ...
7
votes
3
answers
2k
views
How to write attribute-only tables in Geopackages with GeoPandas
I searched around and found similar questions (Writing Non Spatial Table into Geopackage - Python), but that discussion is on a slightly different topic.
Is there a way to write attribute-only tables ...