Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pyshp]

Pyshp is a pure Python shapefile library which can be used to read, write and edit ESRI shapefiles.

0
votes
3answers
102 views

Convert CSV file in shapefile with pyshp/shapefile

I'm trying to convert a file.csv to a file.shp through the pyshp / shapefile module. The content of the CSV is: Lon,Lat,Vel,Dir 15.9576198620869825,41.1791119428255143,9.3949995040893555,92....
0
votes
1answer
30 views

Splitting a Shapefile based off coordinates in Python using osgeo (ogr) or pyshp

I'm having trouble with splitting a shapefile of all the regions in Mongolia into a smaller shapefile based off some input coordinates. The big shapefile I'm trying to split can be found here: https:/...
2
votes
1answer
89 views

PyShp error: Object does not implement __geo_interface__

I'd like to convert geometry to WKT with pyshp and pygeoif using this suggestion, but pyshp throws a following error: Traceback (most recent call last): File "E:/!Projects/imScrape/...
1
vote
1answer
74 views

PointZ elevation issue PYSHP

I have created a shapefile with approximately 300 feature of shapeType POINTZ. I can fill my attributs and define point. Here is my function that i call for each feature: def upd_shp(fn, geo, attr): ...
-1
votes
1answer
205 views

Buffering point shapefile using gdal/ogr: how to copy over input attributes to output shp?

Editing my previous question which asked the best way to buffer a point shapefile in python to add more detail and clarity to what I'm looking for. I have found a method here to iterate through an ...
0
votes
1answer
126 views

automating recording fields in a shapefile via pyshp

I am following the tutorial here for how to convert a csv to shp using pyshp. I am almost there, with one issue. In the tutorial, the person loops over the rows in the csv, and for each field, assigns ...
3
votes
1answer
362 views

Working with shapefiles in Python

I am currently working on the problem of generating roads from Openstreetmap files. I use these Osm files to create a shapefile from all different road types with different roadway numbers, widths and ...
1
vote
2answers
200 views

Converting .csv file to file.shp using Python gives IndexError?

I have a file.csv like the following: 37.0925854357,14.3860984446,0.0000079572,0.0000939491,0.0000028935 37.0978554286,14.5199850398,0.0000041594,0.0000821038,0.0000047924 37.1029267200,14.6538928343,...
1
vote
0answers
48 views

Iterating over pyshp writer object records

The current branch of pyshp has removed the Editor class that combines reading and writing records. The justification is that removing the Editor has been planned for a while now, and might as well ...
1
vote
1answer
345 views

Converting coordinates from shapefile using python?

I am really new to working with this kind of data. I have been trying to work with a shapefile that I wish to convert to geojson. The source has both shapefiles and geojson downloads available, but ...
1
vote
1answer
1k views

Python - Convert csv with unknown number of columns to shapefile

I have this script that converts a csv file to a shapefile. In this case I am specifying manually the name of columns header. Since now I have files with a big and always different number of columns, ...
3
votes
1answer
206 views

Storing a geographic minimum spanning tree with PyShp

I have a list of geographic coordinates (longitudes, latitudes in decimal degrees) as follows: -72.9833,10.6167 -63.1167,10.55 -63.1167,7.91667 -65.9667,10.3167 -67.4333,8.93333 -68.4,10.6167 -70....
3
votes
1answer
282 views

Python pyshp reads some field values as None

Reading the records of AL082017_pts.shp in a recent hurricane path file with pyshp results in a lot of None. Here's the first record: sf = shapefile.Reader('AL082017_pts.shp') print sf.record(0) ...
1
vote
1answer
421 views

Converting Shapefile points to Lat/Long?

Quick Overview of the Project: I have 9000 records of individuals, each with a coordinate pair in a csv. I also have a shapefile/folder(dbf, prj, sbn, sbx, shp, shx) of municipalities within the range ...
4
votes
1answer
4k views

Finding out if coordinate is within shapefile (.shp) using pyshp?

I'm trying to map coordinate data to a municipality. Reverse geocoders aren't as accurate as I need them to be (I was using geocoder pkg before), so I found a .shp that maps and names all the ...
4
votes
1answer
745 views

Using pyshp to read a file-like object from a zipped archive

Presume I have an archive, foo.zip. It contains the parts of a shapefile: foo.shp, foo.dbf, foo.shx, foo.prj, and foo.cpg. I want to work with this shapefile in python, using pyshp, AKA the shapefile ...
0
votes
0answers
71 views

Python (pyshp) coastline Shapefile incorrect visualization

I'm trying to make a set of lines that are equally distant from the nearest coast. for doing this (starting from a coastline shapefile) I'm trying to: find the middle point in each coastline segment ...
0
votes
0answers
355 views

Plotting shapefiles with Pyshp in Python omits some shapes

I want to plot a cloropleth map of Scotland with Pyshp, but only a fraction of the shapes are plotted. The shapefile of Scotland has 32 shapes, and it is available here. The values dictating the ...
-1
votes
1answer
51 views

Getting error while trying to save

I am getting error when I am trying to write out the file. Can somebody help me with this? import shapefile w=shapefile.Writer(shapefile.NEW_SHAPEFILE) w.point(2,5) w.point(2,2) w.point(3,5) w....
3
votes
1answer
281 views

Incorrect transformation when using pyproj

I am using pyproj to work with shp files and am relatively new to GIS. I am tryign to visualize the shp data, but am having a problem as I am incorrectly transforming the coordionates. Here is an ...
1
vote
1answer
168 views

What does the “zone” stand for in proj?

I am using proj, in particular pyproj, to convert from UTM coordinates to the (x,y) coordinates used, for example, by Google Maps. There is a parameter called zone which I could not understand how I ...
2
votes
1answer
88 views

Copy and translate polygonz records according to attributes

I have a polygonz shapefile. I have some records which represents building footprints. I want to copy records according to their attributes 'number of storeys value'. For example, a record has storey ...
1
vote
0answers
210 views

PyShp ASCII encoding error

I want to filter a set of Point Shapefiles using PyShp. That works fine with one of the file sets (one point shapefile) but throws an error for another set that states: UnicodeDecodeError: 'ascii' ...
0
votes
0answers
314 views

Joining CSV to shapefile using pyshp?

I'm generally new to the spatial Python capabilities and have solely used ArcGIS and ArcPy to manipulate shapefiles prior. However, I have a particular use-case that would benefit using my machine's ...
3
votes
1answer
580 views

Creating and reading z values (coordinates) with pyshp?

I am trying to parse an input shapefile which consists of multiple polygons and want to create a new shapefile from this with added z values. Each polygon of the input shapefile is defined by multiple ...
3
votes
1answer
245 views

Pyshp draws polygons out of order after intersection of two shapefiles

I have two shapefiles. One contains electoral borders but not coastline and the other contains provinces and coastlines. I am plotting the electoral districts using Python's pyshp and filling in the ...
0
votes
1answer
243 views

Export selected feature/s to shapefile with open source python library

I need to be able to select one feature/record at a time within a polygon shapefile, regardless of how many shapes it contains, using open source python libraries (e.g., OGR, pyshp, fiona). Then I ...
1
vote
1answer
190 views

How to duplicate features based on attribute value pyshp?

I have a shapefile in which there are a series of polygons that I have to attribute to the name of a project which are recorded in 6 attribute fields. For each polygon there might be one to 6 ...
2
votes
1answer
73 views

How to save a intersection between layers in a shp file?

I have calculated the intersection between polygons in different layers, I got it, and now, I need to save the intersection in a new shp file. I have tried to use QgsVectorFileWriter(), however, I ...
4
votes
1answer
1k views

Write a python function to split polyline shapefile with point shapefile

Update#1 I used the code provided by @GeospatialPython.com in the answer: import os import shapefile from shapely.geometry import * def cut(line_file, point_file, cut_file): """Cuts a line shapefile ...
4
votes
1answer
490 views

pyshp Create Multipatch cube

I am trying to create a Multipatch Shapefile in the shape of a cube. I am using pyshp library and could create one face as a 3D Polygon as described in the wiki of pyshp (Creating 3D Polygons). ...
0
votes
0answers
70 views

Granularity of elevation in GMTED2010 data / understanding shapefiles

Following on from Records of shapefile do not contain every field, where @scruss provided some very helpful Python code. I seem to have a fundamental inability to understand a shapefile (reader ...
2
votes
0answers
390 views

Shapefile “structure” of multipolygon

I am trying to generate a shapefile with Joel Lawheads pyshape-library. This works fine so far, but I have one important question: Is there any mandatory or recommended order of the rings of a ...
1
vote
1answer
283 views

Automate the writing records from csv to shapefile using pyshp module

I have the following data in a csv file('file.csv') Date_Time,Latitude,Longitude,Wind_Speed,Status 09-10-2013/1130,13,93,50-60 gusting to 70,Observed 09-10-2013/2330,13.501,92.501,70-80 ...
1
vote
0answers
50 views

Add spaces to attribute cells when edit record

I generate a shapefile from postgresql's postgis table (I used django pyshp library). My shapefile looks valid, it was successfully opened with ArcGIS 10.1, 10.2, 10.3. But I have a problem: If I save ...
4
votes
1answer
1k views

Export geometry to WKT using pyshp

Is there a straight method to export shapefile geometry (polygon) to WKT using pyshp module for python? I was looking for something similar to OGR's .ExportToWkt() method, but it seems like there's ...
1
vote
2answers
973 views

How do I select shapefiles to be converted to GeoJSON in folder with multiple shapefiles?

How do I only select .shp's to read and then convert to .geojson. The homefolder has 3 different shapefiles and this code currently converts every single file in the folder to a .json. Just trying to ...
3
votes
0answers
217 views

Select shapefile by their coordinates behaviour [closed]

I want to filter shapefiles by their latitude behaviour: If the latitudes of edges A and B are constantly decreasing or increasing then this class marked as correct, otherwise are incorrect. For ...
0
votes
0answers
39 views

Converting csv files into shapefiles using python [duplicate]

I have a csv file which i want to convert in a shapefile. i have seen many questions being asked on this topic but the main problem is all the polygons were of the same size but in this csv file the ...
1
vote
2answers
325 views

Creating polygon grid with un-even spacing between research plots?

I have an orthomosaic of a crop field with small research plots (3.8 X 1.44 m and 0.22m b/w plots and 0.50m b/w range spacing). I would like to create a polygon layer using this information. After ...
1
vote
0answers
412 views

Generating shapefile of polylines using pyshp from a csv file and opening file in qgis

I tried the solution posted in: Creating Polyline from GML using PyShp?, Using PyShp to convert polygons in *.csv to *.shp files? and Using PyShp to create polygon shapefiles? to generate ...
2
votes
2answers
959 views

Creating a really large shapefile without eating all the virtual memory

I am doing something similar to below to create a really large (large than memory on my machine) shapefile: shapes = shapefile.Writer(shapefile.POINT) shapes.autoBalance = 1 shapes.field('MyId','N') ...
1
vote
3answers
989 views

Cropping a Shapefile into a Rectangular Box with Python pyshp

Using 'pyshp' I am hoping to reduce the set of US highway shapefiles to only those in Puerto Rico. The idea is very easy since I only need those pieces which fit into the window. >> import ...
3
votes
2answers
834 views

Identify Census blocks inside urban areas (using pyshp or similar)

I am trying to find the Census blocks that are inside specific urban areas or urban clusters. The Census Bureau provides a list of urban areas/urban clusters with the following information: | ...
1
vote
2answers
1k views

Multiple polygon to shapefile in XYZ format

I have an array of gridded data in XYZ format. I am trying to write shapefile (*.shp) file with multiple polygons with the pyshp Python libraries. I am able to make it for only one polygon with the ...
3
votes
0answers
170 views

Lining attributes up with features when creating shapefile using PyShp?

I used the Python Module Pyshp to select particular census blocks from the Census's shapefiles and package these into a single shapefile. However when I add this data into ArcMap and right click to ...
1
vote
0answers
163 views

Can't get pyshp to work when converting csv to point file [closed]

I've been hammering at it for ages, but I just can't get pyshp to work. The CSV file looks like this: lon,lat -122.5163113, 45.55324148 -95.1719409, 29.97979461 153.0072888, -27.45988559 ... There ...
1
vote
1answer
2k views

Get shapefile polygon attribute value at a specific point using Python (e.g. via PyShp)

I have a shapefile comprising multiple polygons. These polygons have attributes. I am trying to write a script in Python that takes a coordinate point, determines in which polygon it falls, and ...
1
vote
1answer
2k views

Using PyShp to create polygon shapefiles?

I have a script for creating points shapefiles, but I can not fix it for make a new polyline shp file. I have obtained the data from a excel file and extract data in three differents lists Lon,lat,...
2
votes
2answers
320 views

CSV to shapefile missing file

I transform a csv file into a shapefile using the following script: import shapefile as shp import csv import tkinter.filedialog import urllib.request import os a = '...