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

learn more… | top users | synonyms

2
votes
1answer
28 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
36 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 ...
0
votes
0answers
24 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 ...
2
votes
1answer
41 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
34 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 ...
1
vote
2answers
379 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. ...
7
votes
2answers
91 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 ...
1
vote
2answers
45 views

Is it possible to round all coordinates in shapely?

Following on from this question, I'm hitting a problem where thanks to floating point representations, objects aren't precisely where I expect them be after they are moved using affinity.translate. ...
2
votes
1answer
37 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
23 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
28 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
36 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 ...
1
vote
2answers
80 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: ...
2
votes
1answer
95 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
35 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
106 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. ...
2
votes
2answers
133 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
52 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
66 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
61 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
794 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
62 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 ...
0
votes
1answer
59 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
177 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
184 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
44 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
9 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 ...
1
vote
0answers
41 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
77 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', ...
0
votes
2answers
34 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
55 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
1k 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
652 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
61 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
625 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
227 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
26 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
54 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
79 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 ...
3
votes
1answer
71 views

When validating geometries, what are “Nested shells”?

I am validating shapefiles polygon geometry using shapely, and have also attempted it using FME. Some polygons return the error "Nested Shells". I cannot find a definition of what the problem is, ...
1
vote
0answers
71 views

Error and kernel dies with shapely/geos inside Jupyter notebook

I have a Python 2.7 script (code below) that scrapes data from a table on the web and draws a map. It runs fine from the command line using $ python bears.py When I run the identical script from ...
1
vote
1answer
65 views

How to split epsg 4326 linestring in parts consisting of given length in meters in python?

I want to know linestrings (epsg:4326) length in meters instead of degrees. I know that I can use proj4 for that. Here is my code, if you interested. project = partial( pyproj.transform, ...
1
vote
0answers
53 views

Creating spatial layer from MS SQL Server table?

I have a table in MSSQL that I am trying to use to create a spatial layer from using the QgsVectorLayer function to load the table as a layer, and then using Fiona to create a shapefile but I am ...
-1
votes
1answer
78 views

fiona writing geometry into shapefile problem [closed]

Context: I use lxml library that generates some dictionary (infact it is xml attribute dictionary) from xml and i am trying to write these into a shapefile-i.e. get one element-attribute from xml ...
4
votes
2answers
782 views

Reading postgis geometry with shapely

I am doing a small-scale workflow in ipython notebook with geopandas and shapely, pulling a bunch of geospatial data, sometimes from shapefiles, sometimes from postgis (where more expensive processing ...
4
votes
2answers
998 views

Transforming Shapely Polygon and MultiPolygon objects

Is there an easy way of transforming Shapely objects (namely, Polygons and MultiPolygons) from one projection to another without having to dig around and extract coordinates by hand? In fact, I ...
2
votes
2answers
739 views

Maximizing Code Performance for Shapely

I've written this code in order to calculate the percent cover of grassland within a national park, within 20km^2 of points of recorded occurrences for a species. It is designed to only consider the ...
3
votes
1answer
137 views

What is Shapely library alternative in R?

I want to manipulate 2D geospatial geometries in R. I am used to using Shapely in Python but I am a newbie in R. Can you suggest Shapely alternatives for R?
4
votes
2answers
312 views

geopandas/shapely: what units it uses/calculates for area and distance functions?

it looks like a silly question, yet I can't find clear answer on that: what units geopandas/shapely use calculating distance/area between objects?
1
vote
1answer
372 views

GeoPandas: return lat and long of a centroid point

I would like to return the lat and lon or x and y from the point object in the following series as I plan to link them with an API I built that links OSM and NetworkX. The centroids will be added as ...