The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [fiona]

Fiona is OGR's new, neat, Pythonic API

Filter by
Sorted by
Tagged with
0
votes
1answer
59 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
2answers
31 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
19 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 ...
0
votes
1answer
105 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, ...
3
votes
1answer
107 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
140 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
131 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
53 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
32 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 ...
0
votes
2answers
98 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 ...
3
votes
1answer
96 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
293 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 ...
1
vote
0answers
57 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
70 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 ...
0
votes
0answers
57 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 ...
3
votes
1answer
97 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'...
0
votes
1answer
267 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....
2
votes
1answer
214 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
139 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....
2
votes
1answer
134 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 ...
0
votes
0answers
204 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
217 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 ...
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 ...
0
votes
0answers
84 views

Splitting aerial photography into images with GPS coordinates

Splitting aerial photography into images with GPS coordinates Given this folder structure of (four) Oblique and (one) Vertical aerial photography of 10 cm resolution: dir/Orientations/footprints.cpg ...
2
votes
1answer
1k views

Snap points shapefile to line shapefile using shapely

I have 2 datasets: 1) a road network shapefile which has many polylines and 2) a bus stop shapefile which has many points representing bus stops. My points shapefile has CRS of EPSG 4326 and my line ...
2
votes
1answer
49 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 ...
1
vote
1answer
92 views

Why does shapely intersection of two lines change behaviour when fiona module is imported?

I am having issues with calculating an intersection of two LineStrings using Shapely. Such an intersection should return a point, yet my code returns a LineString. I found a simple example of an ...
0
votes
1answer
490 views

Create Shapely linestring from string of coordinates in text format

I have a DataFrame where one column consists of lines stored like so: '[[-7.61, 42.15],[-6.62, 43.16],[-8.9, 41.0],[-9.2, 40.5]]' Is there an easy way to read these lines directly into shapely ...
1
vote
0answers
134 views

Basic Python plotting [closed]

Sorry if I sound like I don't understand, but I've been reading around trying to figure out how to do geospatial plotting in Python. I keep running into errors despite the examples I've seen appearing ...
0
votes
1answer
256 views

Using GeoPandas, Shapely and Fiona to “select” state from shapefile, save it and display it? [closed]

I have the usual US census states shapefile for the 48 contiguous states. I am trying to select a state of interest from that shapefile then save that shapefile and display. I want to use GeoPandas, ...
3
votes
1answer
568 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': '...
2
votes
0answers
303 views

How to get fast writing with Geopandas & Fiona?

I have a GeoDataFrame with 1,2M records, and want to write it into a GeoPackage file. Currently, it takes >20 minutes, and, as I calculated, average write speed is 100 recs/sec. As I read in the ...
5
votes
2answers
6k 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)....
1
vote
0answers
68 views

Spatial join of building footprints with Shapely and Fiona

I would like to do a spatial merge of the address nodes of Baton Rouge into their surrounding building footprints. Every building (polygon) should get the properties of the address (point). Here is ...
1
vote
1answer
214 views

Take pixel locations from rasterio raster and write out shapefile

I'm pulling a satellite image into python with rasterio, running some analysis to find a specific bounding box within that image, and then want to write those points out as a shapefile. I'm struggling ...
1
vote
0answers
50 views

Why does my Fiona output look different from my image

I'm trying to export my houghlines as a shapefile, which works. But the output the lines in my shapefile are very different then the generated hough lines that are shown on the image. Example: The ...
0
votes
1answer
276 views

Dissolving polygons based on multiple attributes with Python (shapely and fiona)?

I would like to dissolve a polygon shapefile based on two different fields, using Python and open source libraries. I'm just able to dissolve the shapefile using one single field, with Gene's answer ...
1
vote
1answer
144 views

Error creating buffers in shapefile

I have a function to create buffers from everything in a shapefile, but I'm getting an error on some files: Record's geometry type does not match collection schema's geometry type: 'Polygon' != '...
0
votes
1answer
147 views

Print just coordinates

I am relatively new to coding, but I am using fiona within python and would like to print the coordinates that make up the points of the polygon to later add to a separate list. However I am having a ...
2
votes
1answer
143 views

Clipping a raster by polygon and getting the sum of pixel values in webapplication

I am loading a layer with points and a raster one in an OL2 map. The layers come from a geoserver. What I want to do is to apply some buffers to the points and based on the buffer to get the sum of ...
1
vote
0answers
51 views

How to read coordinates in this specific format

I'm trying to create a shapefile consisting of lines from my python output. The output of the function is : [[[400 421 427 114]] [[227 475 237 356]] [[408 383 427 124]] [[456 322 500 327]] [[436 ...
1
vote
1answer
465 views

Reprojecting coordinate system with Python and lat/lon is only slightly off [duplicate]

I am using Python to reproject a shapefile (called "SCL" in my project) into a new coordinate system that will allow me to plot it on the same map as another shapefile (called "PUMA" in my project). ...
1
vote
0answers
1k views

NameError: name data_all1 is not defined in Python 3.x

I have a standalone script using data opened from a Geopackage with Fiona. When I run this portion of my script: import os import fiona import numpy as np datapath= '/media/sf_SharesShapefiles/' ...
2
votes
1answer
172 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 ...
5
votes
2answers
883 views

Changing shapefile's field type using fiona?

I need to have a layer time-enabled for Esri application-making. Coming from the source, it has an int type column called year. I need to find a way to automate its conversion to date. I first tried ...
2
votes
1answer
973 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 = "...
0
votes
0answers
22 views

Out schema for dissolving shapes

I have a code which goes like this with fiona.open(some_file, 'r') as to_dissolve: out = to_dissolve.schema with fiona.open(another_file, 'w', 'ESRI Shapefile', out) as dissolved: # ...
0
votes
0answers
32 views

Shapely not detecting Manhattan point in Pluto dataset

I have a shapefile for Manhattan taken from the Pluto dataset: https://www1.nyc.gov/site/planning/data-maps/open-data/dwn-pluto-mappluto.page Removing it from the zip, I load it with Fiona. import ...
0
votes
1answer
198 views

Read OGR VRT file using Fiona

Using Fiona for reading my VRT file I'm receiving an error that OGR_VRT driver is not supported: fiona.errors.DriverError: unsupported driver: 'OGR_VRT' My test.vrt file looks like: <?xml ...