shapely

How to install geos on debian raspberry pi

拥有回忆 提交于 2019-12-11 04:02:04
问题 Hi I am trying to install geos on a raspberry pi running rasbian wheezy so that I can include the shapely modules in my python scripts. I tried using: git clone git://git.debian.org/git/pkg-grass/geos this downloads properly, but when I try to run my python script it gives me a traceback error saying OSError: Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so'] have I put geos in the wrong place? is there a special way to build the files? Thanks for

Why can shapely/geos parse this 'invalid' Well Known Binary?

我只是一个虾纸丫 提交于 2019-12-11 03:54:15
问题 I am trying to parse Well Known Binary a binary encoding of geometry objects used in Geographic Information Systems (GIS). I am using this spec from ESRI (same results here from esri). I have input data from Osmosis a tool to parse OpenStreetMap data, specifically the pgsimp-dump format which gives the hex represenation of the binary. The ESRI docs say that there should only be 21 bytes for a Point , 1 byte for byte order, 4 for uint32 for typeid, and 8 for double x and 8 for double y. An

Shapely contains(point) always gives False

我的未来我决定 提交于 2019-12-11 01:56:27
问题 I started working on geopandas and shapely today and I am trying to use the contains method to check if a point lies inside a polygon of geological constituency data from here. My code is: if janak.boundary.contains(cent_janak): print('True') else: print('False') where janak is a polygon from geometry data of a shapefile and cent_janak is the centroid of janak. To verify, I plotted them like this from descartes import PolygonPatch BLUE = '#6699cc' poly= janak fig = plt.figure() ax = fig.gca()

Packing an irregular polygon with different sized circles

懵懂的女人 提交于 2019-12-10 16:17:04
问题 I'm trying to write a program in Python with Shapely that takes in shape files (right now congressional districts) and "packs" them with circles. The end goal is to have the center points and radii of the circles. I'd like to cover the maximum area with the least amount of circles. All of the resources I've found via Google so far are about circle packing within standard geometric objects like squares/circles/triangles etc... So my instinct is to try and turn these shapes into triangles or

How to create GeometryCollection from geojson with python shapely?

我们两清 提交于 2019-12-10 13:12:16
问题 I want to calculate areas of geometries and some of these geometries can be geometry collections. But I can't do this because shapely doesn't create geometry collection from geojson. Here is the sample code: import sys import shapely from shapely.geometry import shape print sys.version print shapely.__version__ shp = shape({ "type" : "GeometryCollection", "geometries" : [ { "type" : "MultiPolygon", "coordinates" : [ [ [ [ -176.392059198913, -44.2871679740063 ], [ -176.392051742896, -44

Using cascaded_union to combine shapes gives “ValueError: No Shapely geometry can be created from null value”

五迷三道 提交于 2019-12-10 12:39:31
问题 I have a cluster of seven overlapping circles and ellipses that I'm trying to combine into one shape, but when I run cascaded_union() I get the error: ValueError: No Shapely geometry can be created from null value Here's what I have written so far: import numpy as np import matplotlib.pyplot as plt from shapely.geometry import Polygon from shapely.ops import cascaded_union x = [-1.86203523, -1.91255406, -2.03575331, -2.16247874, -2.22159676, -2.17992322, -2.06085035, -1.93121615, -1.86378696,

How to check if a polygon is empty in Shapely?

試著忘記壹切 提交于 2019-12-10 01:38:14
问题 I'm pretty new to Python so the answer to this question is probably quite simple, but I've looked everywhere and tried a lot but couldn't find the answer. Simplifying a polygon using Shapely may result in an empty polygon. I want to replace the polygon with a point if the polygon is empty. Something that would work like: if mypoly is empty: mypoly = [(0,0)] 回答1: Given that mypoly is a shapely polygon, you can check if it's empty using is_empty which is built in to Shapely to check for empty

Cut a polygon with two lines in Shapely

折月煮酒 提交于 2019-12-10 01:02:50
问题 I am trying to cut a shapely.geometry.Polygon instance in two parts with two lines. For example, in the code below, polygon is a ring and if we cut it with line1 and line2 we should get two partial rings, one w/ 270 degrees and one with 90 degrees. Would there be a clean way to do this? from shapely.geometry import Point, LineString, Polygon polygon = Point(0, 0).buffer(2).difference(Point(0, 0).buffer(1)) line1 = LineString([(0, 0), (3, 3)]) line2 = LineString([(0, 0), (3, -3)]) 回答1: There

Shapely Split LineStrings at Intersections with other LineStrings

本秂侑毒 提交于 2019-12-07 06:41:37
问题 I have a set of LineStrings which are intersected by other LineStrings and I want to split the LineString into separate segments at these intersection points. I have a solution but I don't think it's the best approach. Let's say we are dealing with one LineString: >>> import shapely >>> from shapely.geometry import * >>> import geopandas as gpd >>> >>> MyLine=LineString([(0,0),(5,0),(10,3)]) >>> MyLine <shapely.geometry.linestring.LineString object at 0x1277EEB0> >>> And 2 lines that

Interpolating every X distance along multiline in shapely

走远了吗. 提交于 2019-12-07 04:01:14
问题 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 100m), returning shapely point objects every 100m, how can I achieve this? Here is what I have so far, but it only returns one distinct point (when I know it should return several thousand, as tested in ArcMap): points = [] for x in range(100,50000,100): x,y = multiline.interpolate(x).xy xy = (x[0]