Questions tagged [fiona]

Fiona is OGR's new, neat, Pythonic API

Filter by
Sorted by
Tagged with
2
votes
1answer
1k views

Fiona fails to write CRS to shapefile

I wanna save some geometry to a shapefile with the python27 module fiona and manually specify the coordinate reference system (CRS). Here's what I tried: import fiona import fiona.crs outpath = "...
3
votes
0answers
56 views

Setting DXF colors via Fiona

One might expect that the "Color" CAD field would control this, but the driver doesn't allow it to be set. schema = {'Layer': 'str', 'Color': 'int'} with fiona.open(path, 'w', 'DXF', schema=schema) ...
8
votes
2answers
1k views

Rasterio does not execute the rasterize function

Rasterio's features.rasterize() function is not working as expected. I have two files: OpenStreetMap shapefile with land usages Raster (.tif) with satellite imagery Goal: Create a raster file from ...
1
vote
2answers
660 views

Different output for Fiona Shapefile CRS [closed]

I'm trying to read the crs property on a shapefile to validate projection. Below I contrast fiona documentation with what is output on my console. Either output would be fine for my use case, but ...
10
votes
5answers
8k views

Reading raw data into geopandas

Is it possible to read raw data into a geopandas GeoDataFrame, a la a pandas DataFrame? For example, the following works: import pandas as pd import requests data = requests.get("https://data....
3
votes
1answer
50 views

Find the closest line to a polygon Python Rtree

I have a series of fields and roads I am trying to find the nearest road to each field. I want to add field to each of my polygons with the index/name/etc of the closest road. Would this be the ...
1
vote
1answer
30 views

How to write a multi geometries .geojson file with Shapely/Fiona?

I am very new to fiona and shapely, and trying to do something that doesn't seems to be designed : I have a list of points and a shapely.MultiPolygon (Voronoi polygons from the previous list of points)...
0
votes
2answers
93 views

Python convert lines string to polygon if closed

I have a series of contour linestrings some are closed and some are not. The linestring values are between -1 and 1. I am trying to create polygons from the linestrings if they close and keep the ...
10
votes
6answers
10k views

Fiona ImportError: DLL load failed

I've been using the great Shapely/Fiona combo successfully on Linux, but now i need to create a kind of production environment on windows and theres only one problem. When i try to import fiona, i get ...
0
votes
1answer
2k views

geopandas error when writing to_file() “ValueError: 'long' is not in list”

I'm having a problem getting the "to_file()" function to work with geopandas import geopandas as gpd f = gpd.read_file('fin.shp') f.to_file('fout.shp') Error Output: ---------------------------...
1
vote
1answer
80 views

Convert lines to polygons with shapely polygonize

I have a line shapefile that I am trying to convert to polygons with python using fiona and shapely. inFile = '/content/drive/My Drive/polyline.shp' outFile = '/content/drive/My Drive/polygon.shp' ...
0
votes
0answers
41 views

Reading GeoPackage file bigger than RAM size with GeoPandas?

I have a gpkg file that's around 10GB, and 8GB of RAM. So, if I were to read my file: import geopandas as gpd fp = "/path/to/my/file.gpkg" data = gpd.read_file(fp) print(data.shape) My computer ...
3
votes
1answer
660 views

Creating shapefile file with Fiona and GeoPandas?

I am trying to create a shapefile and a geojson using geopandas and fiona. import fiona import fiona.crs ... geometry = [Point(xy) for xy in zip(df['longitude'],df['latitude'])] crs = {'init': '...
0
votes
1answer
123 views

Getting CRS to export shapely polygon to shapefile

I am trying to export a shapely polygon to a shapefile. I have tried this, but the CRS is missing, when I try to import it in to QGIS. The shapely polygon is from this OSMNX example but edited to ...
0
votes
1answer
142 views

Installing rasterio and Fiona together?

I work on Windows; I use Christoph Gohlke wheels; Python 3.7 After installing GDAL-3.0.1 and Fiona-1.8.6 an error occurs on import of fiona from fiona.ogrext import Iterator, ItemsIterator, ...
0
votes
2answers
32 views

Getting MemoryError from Fiona when merging large amounts of buffered data (Python)

I am using fiona and shapely together to buffer points and then merge them and write them to a shapefile. For almost all of my datasets, this is working fine. However, I am currently getting a ...
1
vote
0answers
23 views

Obtaining least number of grids (polygons) covering a separate polygon while the grids are overlapping

I have grids as polygons where the grids are overlapping. I want list of grids covering a separate polygon. The image below demonstrate the problem. The red lines are the edges of the grids and the ...
3
votes
1answer
197 views

Convert contours to polygons maintaining attributes using Python?

I have a series of polylines(contours) that i want to convert to polygons using Python (GeoPandas, Fiona, Shapely). Because these are contours, there will be donut polygons, can anyone point me to how ...
2
votes
1answer
187 views

Unicode problems while writing selected features to a new shapefile with Fiona

I have a shapefile with a large number of geographic features (marine protected areas). I'm trying to read through all of the areas in the shapefile, select those that fit a certain criterion, and ...
3
votes
1answer
118 views

Writing Non Spatial Table into Geopackage - Python

Just wondering how to write a non spatial (aspatial) table to geopackage using python. I have attempted using Fiona, geopackage = 'some_geo.gpkg' layer = 'test_layer' schema = {'geometry': {'type'...
9
votes
1answer
9k views

Rasterize a shapefile with Geopandas or fiona - python

I need to rasterize a really simple shapefile a bit like this http://tinyurl.com/odfbanu. Which is just a shapefile coutaining counties in the US.I have seen this previous answer : GDAL RasterizeLayer ...
7
votes
1answer
4k views

Plot shapefile on top of raster using plot and imshow from matplotlib

I need to plot a shapefile on top of a raster. I would like to use the python package rasterio and some combination of fiona or geopandas to load the shapefile. I found an example in the rasterio ...
2
votes
1answer
196 views

Creating equally spaced coordinates on California state map created with basemap?

I have created a California state map with basemap Python library and this shapefile. Code is below from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt fig, ax = plt.subplots(...
1
vote
1answer
233 views

Geopandas read_file only reading first part of KML

I am trying to read the following file with GeoPandas: import geopandas as gp gp.io.file.fiona.drvsupport.supported_drivers['KML'] = 'rw' df = gp.read_file('http://watchthemed.net/index.php/json/...
0
votes
0answers
96 views

Fiona installation in Python 3.6 ERROR: Command “python setup.py egg_info” failed with error code 1 [duplicate]

I'm trying to install Fiona using pip in Python (v 3.6.8). I'm using the following command: python36 -m pip install Fiona I'm getting the following error:
1
vote
0answers
34 views

Select features of a shape which are not in another shape

I have a shape with some features (let's say 100) and a second shape with some of this features (50) buffered (5 meters inside buffer). I want to select and write in a new shape every feature of the ...
5
votes
2answers
2k views

Reading/writing utf-8 encoded data using Fiona?

So I have a 'cpg' file with my 'in_file' shapefile data (definitely set to 'utf-8'). I was using 'meta' to create the same schema/crs as 'in_file'...though it runs, my text fields are borked on ...
0
votes
2answers
135 views

Fiona and Geopandas not applying CRS to shapefile during creation

I'm trying to create a shapefile of points from a coordinate list. But, when I use fiona to create the shapefile Arc Catalog is showing that there is no CRS. I tried to add the CRS with Geopandas and ...
2
votes
1answer
752 views

Adding a Property (attribute) to a geometry in Shapely/Fiona

Once you have line and polygon geometries, intersection using Shapely is very straight forward. What I did after that is to integrate all the looped 'intersected' geometries into a MultiLineString. ...
7
votes
2answers
8k views

How do I write a GeoPandas dataframe into a single file (preferably JSON or GeoPackage)?

I'm new to GIS and having a basic beginner problem. I've got data in the form of a geopackage .gpkg from GADM.org. I can read in and use the data without problem using Geopandas (via built-in Fiona)....
3
votes
1answer
101 views

Using libraries other than PyQGIS to develop plugin for QGIS?

I develop a plugin for QGIS. Before to integreted it in the QGIS I developped it with GIS library (Fiona, shapely, geopandas, ...) and it work well. Now I try to build it with plugin_builder of QGIS. ...
2
votes
1answer
431 views

Quickly find all polygons that overlap with two or more polygons in Shapely

I have a set of Polygons (in Shapely) that I wish to find all intersections that are comprised of overlaps of two or more polygons. I have been working based off the code found in this answer. I have ...
0
votes
0answers
64 views

Writing only one of the input vector fields to output vector using Fiona/ Python?

I'm working on a function to perform operations on folders of vector files. These files might have differing attribute fields but there will be a common field between them. I'm using fiona in python ...
2
votes
0answers
86 views

Creating a shapefile within a zip file with Fiona

According to the Fiona documentation "Fiona lets you read and write zipped Shapefiles." But I can't find any examples of writing (with Windows file paths). Trying this... with fiona.open('output_shp....
1
vote
0answers
85 views

How to segment polygon in to line segment?

I want to segment a Polygon or PolyLine in segment of line and remove some segments. I have an polygon that i convert in polyline by the code below and it work well: from shapely.geometry import ...
16
votes
3answers
15k views

Generating GeoJSON with Python

I want to programmatically create a GeoJSON file using polygons from a shapefile but adding attributes from my own application. This is easily done for a shapefile: def create_data_dayer(self,...
3
votes
3answers
12k views

MultiLineString to separate individual lines using Python with GDAL/OGR, Fiona, Shapely

There are lots of MultiLineString features in a polyline shapefile. The problem is to split these lines into separate individual lines. There is a similar question with PostGIS, but I need to code in ...
10
votes
1answer
4k views

Drivers of Fiona

What drivers does the python package fiona have? When I check the manual it says [...] and the possible formats are enumerated in the fiona.drivers list. However, when I type in python from fiona ...
0
votes
1answer
347 views

Dissolving polygons to single part features with Python (shapely and fiona)?

I used the code from Dissolving polygons based on multiple attributes with Python (shapely and fiona)? to dissolve a shapefile using shapely and fiona. However the output creates multi-part geometries....
1
vote
2answers
568 views

Using Fiona to Convert file geodatabase to PostgreSQL / PostGIS?

Is there a way to use Fiona instead of OGR to convert a GDB over to postgresql / postgis within Python? If so, how or where can I look? I cannot seem to find this within the Fiona site or by simply ...
5
votes
5answers
9k views

How to install Fiona to read Shapefile attributes with OSGeo4W?

I´m developing a plugin in Python and I need to read the shapefile attributes, so I found the Fiona API and dbfpy also but I don't understand how to install these packages because I install the QGIS ...
2
votes
1answer
296 views

How can I avoid changes to field types in geopandas?

I am using geopandas in the following routine to create the union of 2 (polygon) shapefiles: import geopandas as gpd def union(fn_A, fn_B, output): shpA =gpd.read_file(fn_A) shpB =gpd....
0
votes
0answers
175 views

Geopandas to_file() gives an error regarding fiona.drivers(). Is it possible to work around this?

I'm using geopandas to get WKT and coordinates from a database: df = pandas.read_sql(con=conn2, sql=test_query) df['Coordinates'] = df['WKT'].apply(lambda x: wkt.loads(x.read())) gdf = geopandas....
17
votes
1answer
7k views

Finding Nearest Line Segments to Point using shapely?

Background From a known Point, I require to establish the nearest surrounding "visible perimeter" against a table of MultiLineStrings, as shown on the diagram. I've searched this site with a number ...
2
votes
1answer
177 views

Sorting (ORDER BY) rows from Shapefile using Python?

I'm writing a Python script where I have to read a Shapefile, sort its rows/records by a specific field, and then write a new shapefile with that new order. Does anyone how can I do it? I'm using ...
1
vote
0answers
237 views

Write feature collection to S3

Is there a way to write a feature collection from Python memory to an S3 bucket (as Esri Shapefile, zipped Shapefile or something else) without writing it first to disk? I tried writing to a ...
2
votes
1answer
265 views

Calculating Length of Line features using GDAL, Shapely libraries of Python [closed]

I have a line shapefile named "river" which has 385 features. I would like to calculate the length of each feature using Python. I am currently using GDAL, Shapely, and Fiona libraries.
2
votes
0answers
1k views

How to prevent “Type error: unhashable type” while writing properties with Fiona?

Using shapely's dissolve method I created new geometries from two existing shapefiles. Now I would like to save those new geometries and their properties with Fiona. I have tried to write the ...
2
votes
1answer
53 views

Python Fiona affecting external GDAL binaries?

Curious if anyone else has encountered this before and may have an explanation: In my Python workflow, I'm importing fiona (1.8.4) to manipulate shapefiles, and then later downstream I'm shelling out ...
3
votes
1answer
2k views

Open GPKG embedded layers in python

I have a gpkg with multiple tables, and I am trying to load it with geopandas: import geopandas as gpd filename = '~/example.gpkg' gdf = gpd.read_file(filename)' This returns the first table/layer ...