Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects.

learn more… | top users | synonyms

1
vote
2answers
448 views

Why can't Basemap's readshapefile read the world_adm0 shapefile?

I'm using the world shape file that can be found at https://trac.openstreetmap.org/browser/applications/editors/merkaartor-branches/merkaartor-0.14-fixes/share/world_shp/world_adm0.shp?rev=17052. ...
5
votes
2answers
2k views

how would one get the end points of a polyline?

I am attempting to write a script to get the end points of a series polylines, and then use those end points to create a polygon. I'm not sure which tools to begin to use on this project. I would ...
2
votes
2answers
37 views

Find common borders of features and get their attributes using fiona and shapely

I would like to find neighboured features in a shapefile using fiona and shapely. As shown in this answer http://gis.stackexchange.com/a/95595/62250 it's easy to get common borders between features. ...
0
votes
1answer
29 views

How to Convert 3D coordinates to 2D coordinates for R-Tree?

I am trying to implement a bounding box via a spatial index and get an error stating that I must either provide coordinates as either (minx, miny, maxx, maxy) or (x,y) for 2D indexes. I've tried ...
1
vote
1answer
50 views

How To Properly Implement a Bounding Box for Shapely & Fiona?

I am trying to spatially analyze two layers within same GDB file using Python / Shapely. Another user was kind enough to give me a procedure to go by in trying to reduce the number of senseless ...
1
vote
0answers
62 views

Find Properties of Nearest Line Segments to Point in Python

I have been trying to find a workable Python approach to finding nearest line segments to one (or more) points, and came accross @gene's solution to @RustyMagoo's problem here: from shapely.geometry ...
1
vote
0answers
37 views

Spatially Analyzing two layers within same File Geodatabase using Python / Shapely?

I'm using a nested for-loop to do Shapely analysis between two Python lists created via two pre-reads of the same GDB file. One list contains all the features of a particular layer while the other ...
3
votes
2answers
167 views

Can this Be Recoded to Be More Efficient with Respect to Processing Time?

I'm very new to GIS but have been asked to parse through any given ESRI GDB file-folder without using any ESRI product. I've been trying to focus on using Fiona and Shapely as these seem to be ...
0
votes
0answers
29 views

How to do a Python / Fiona / Shapely equivalen to an ESRI ArcPy SpatialJoin?

I'm a GIS noob, but I am trying to learn as quickly as I can. Please bear with me. How can I identify what structures from one layer are WITHIN in some body of water in another layer? My problem ...
1
vote
2answers
149 views

How to polygonize raster to shapely polygons

I am seeking an open-source python solution to convert raster to polygon (no ArcPy). I did know the GDAL function to convert raster to polygon, and here is the manual: http://pcjericks.github.io/py-...
1
vote
1answer
39 views

How to Parse Through a ESRI GDB File/Folder After Opened with Fiona?

I should point out that I'm a noob. I'm playing around with making a python gui app and believe I have opened an ESRI GDB file/folder using: with fiona.open(GDBPath, 'r') as sourceGeoData What I'd ...
1
vote
1answer
102 views

Assign a point to polygon using pandas and shapely

I have a series of Easting and Northing coordinates in pandas dataframe along with other columns of information. I know the coordinates fall within and administrative area and want to match the ...
3
votes
2answers
623 views

Area in KM from Polygon of coordinates

I have polygons from coordinates in (python shapely) that looks like this POLYGON ((24.8085317 46.8512821, 24.7986952 46.8574619, 24.8088238 46.8664741, 24.8155239 46.8576335, 24.8085317 46.8512821)) ...
1
vote
2answers
88 views

Is it possible to round all coordinates in shapely?

Following on from How can I add points to a LineString in shapely?, I'm hitting a problem where floating point representations mean objects aren't precisely where I expect them be after they are moved ...
0
votes
1answer
84 views

Check if point is within radius of another point with Shapely

I've successfully used Shapely with python to check if a point is within one of a set of polygons in a .shp file but now would like to check if a point is within a circle of radius x miles from ...
2
votes
1answer
39 views

How to create a Null shape in shapely

I want to create a valid Shape object in shapely which has properties but has no geometry. e.g. For creating features to be saved into a shapefile. All features have attributes/properties but some ...
0
votes
1answer
52 views

importing fiona before shapely raising geos-related OSError

I ran into an issue where the order of imports for fiona and shapely caused the following geos error below which happens when i import fiona before shapely. If I do the reverse all is fine. Must be ...
2
votes
1answer
87 views

Get intersection of circles shapely

I have a List of Points which I transform to circles. Code from here circles = [Point(random.random(), random.random()).buffer(random.random() * 0.1) for i in range(3)] I want to know which circles ...
0
votes
2answers
47 views

Trouble getting shapely to run

I downloaded the GDAL complete Framework von Kyngchaos which also includes the GEOS Framework and shapely for python. I can import shapely without a problem, but when I try to perform some "geo ...
7
votes
2answers
130 views

Polygons across international dateline [-180..+180 longitude]

I'm trying to generate polygons for satellite orbital swaths. So far I have a method to generate two lines which represent the edge of each swath in [lat,long]. Some of the swath's cross the ...
2
votes
1answer
56 views

Add SRID to Point

When inserting a point into a PostGIS database I do it using ST_GeomFromText('POINT(0 1 2)',26918). Note that this was done on a tutorial database where the SRID was set manually as explained ...
0
votes
1answer
56 views

How can I add points to a LineString in shapely?

I have two Polygons which intersect along one edge as shown below. I need to add the red vertices at each end of the intersection to the blue polygon. I thought I could do this with by calling ...
1
vote
1answer
69 views

How to simplify borders between polygons in shapely?

I have some fairly complex, and not completely accurate shapes stored as shapely Polygon objects. I'm trying to find the common borders, which should be as easy as finding the LineString returned from ...
1
vote
1answer
50 views

How to find the area with most intersection for buffer regions?

Find the area with the most intersection This question relates to previous question asked - How to find the intersection areas of overlapping buffer zones in single shapefile?. I tried to find ...
2
votes
1answer
170 views

How to find the intersection areas of overlapping buffer zones in single shapefile?

Find the intersections of the buffer zones I found an example where they tried finding the intersection of two different shapefiles -Intersect Shapefiles using Shapely. I've tried to adapt my code to ...
0
votes
0answers
55 views

cartopy: plotting shapefiles

I am new to gis and am trying to plot a shapefile containing land polygons. (From OSM.) Unfortunately my output image is always empty (i.e. white). Can somebody tell me what I am doing wrong? import ...
2
votes
3answers
112 views

I have an existing attribute table that I'd like to add values to the fields within it while preserving the geometry, how can I do this?

I've tried to use fiona and shapely and ogr, but the tutorials seem to be insufficient to describe how to do such a seemingly simple task. In arcpy this could be done simply with an update cursor. I'...
2
votes
2answers
261 views

Shapely Distance different from Geopy/Haversine

I am running a specific analysis where we use shapely to create buffers around points (store locations) and then check if other points (user locations) are present within that buffer value. When i ...
0
votes
1answer
85 views

How to access members of GeometryCollection - Python

I am using 'intersection' function from Shapely to find junctions of a road network. As i found, intersection returns GeometryCollection. In my case it could be Point, LineString or perhaps ...
1
vote
1answer
71 views

Points to irregular grid

I have a huge dataset (millions of points) and a irregular grid (quadtree) in shapefile format and I need to convert the points in countes over the grid provided. I managed to make it work, using ...
1
vote
1answer
90 views

Difference between Crosses & Intersects - Shapely (Python)

I have two questions : I have some lines (eg: road network). I want to find coordinates of each junction. Should i use crosses or intersects function from python's Shapely module? They are giving ...
1
vote
1answer
834 views

How do I find out if a given lat lon is in a KML Linear ring using shapely?

I'm a GIS basic/novice user. I have some LinearRings in a KML file that give the areas for a bunch of different regions. And then I (will) have some lat lons that I want to test to see if they're ...
2
votes
1answer
108 views

Converting Shapely MultiPolygon to Polygon: Technique doesn't always work

In order to get the exterior coordinates I need to convert a shapely MultiPolygon to a Polygon. I do it like this: if poly.geometry.type == 'Polygon': x, y = poly.geometry.exterior.xy elif poly....
0
votes
1answer
64 views

Cut a linear feature according to the directions or azimuths

I have a shapefile linear that contains a single items as in the image and I want to divide it into several section respecting the azimuth and the line direction. i have this code : import os ...
5
votes
2answers
338 views

intersecting two shapefiles from Python or command line

I'm new to working with geo data and trying to address a similar question to the one posted here. Using command line and/or shapely/fiona, in the most efficient and elegant way. I created two ...
8
votes
3answers
193 views

“Greedy” clipping lines with polygon

I am wishing to clip a set of polylines (black lines in image below) to the outer boundary of a polygon. Any voids within the polygon should be ignored. My ideal output are the dashed yellow lines. ...
1
vote
0answers
60 views

How do I create a raster file from a geopandas dataframe storing lats, longs, values, and geometries

From a text file with time, lat, long, and cf values, I create a pandas dataframe (cf_df). Then I use the lat, long values to create a geoseries and create a geopandas dataframe from the original ...
0
votes
0answers
18 views

Converting branched multiline into series of single lines in shapely

If I have a multiline string representing a branched network with a common starting point (red network in pic below): Does anyone know how to convert this to a set of individual single linestrings ...
2
votes
0answers
64 views

Interpolating every X distance along line in shapely

If I have a shapely multiline object that contains many lines whose total length each is 50km (when traced from the origin), and I want to interpolate along the multiline every X meters (let's say ...
1
vote
1answer
129 views

fiona ValueError: invalid literal for int() with base 10: 'str'

Why below code does not work- import fiona from fiona.crs import from_epsg my_schema = {'geometry': 'Point', 'properties': {'mean_in': 'str', 'total_h1': 'str', 'total_h2': 'str', 'LOS': 'str', 'id':...
0
votes
2answers
37 views

Shapely Not Determining Point in State

I am pulling State geometry data from a database (populated from Shapefiles) to find what state a coordinate pair is in. I was originally using GeoAlchemy, but tens of thousands of queries to ...
0
votes
0answers
83 views

Using shapely and geopandas in pyspark

I'm new to geospatial analysis and trying to start the analysis using python. Since the data is too huge we are trying to make use of hadoop and spark to get the analysis done. I would like to use ...
6
votes
2answers
2k views

Dissolve polygons based on attributes with Python (shapely - fiona)

I have been trying to create a function that does basically the same thing that the QGIS "dissolve" function. I thought it would be super easy but well apparently not. So from what I have gathered ...
-1
votes
1answer
694 views

Calculating intersection between points and polygon in shapefile

I want accomplish the following using command line python tools only (shapely + fiona) I was wondering if there was a straightforward way for me to do the following: Read in a shapefile (all ...
1
vote
0answers
91 views

Projecting GeoJSON polygon object in python to calculate area

I have a script, written in python, that does many calculations - but one set of calculations hinges on determining the area of a polygon that I read in, in GeoJSON format. I can convert this object ...
16
votes
1answer
667 views

Calculating Focal Statistics for Special Neighborhood?

I'm looking to calculate focal statistics for each cell of a raster, within a neighborhood of a specified criteria. Background - I have three binary rasters, each representing a single vegetation ...
0
votes
2answers
339 views

Point in Polygon - geojson - using Shapely / Python returning incorrect results

I'm trying to test if a point is inside a polygon using this example: http://stackoverflow.com/questions/20776205/point-in-polygon-with-geojson-in-python However, my output says that none of the ...
4
votes
0answers
28 views

“Merging” 2 layers of LineString with splits at intersections

I would like to "merge" 2 networks of lines and these lines need to be split when they intersect. With pictures it should be clearer : What to do: if a black line intersects a red line, they ...
0
votes
0answers
57 views

Intersect using Open Source GIS [duplicate]

I have a CSV containing user locations (has lat, long, userid, timestamp). I have a countries shapefile (has country name, geometry - got this from thematicmapping.org). I am trying to append a ...
0
votes
0answers
115 views

Calculating distances with lat/long in decimals and WGS 84

I need to calculate the distance between points of two different datasets, once with locations of towns, the other with locations of dams. Both are located in different countries in Africa. The more ...