polygons

Produce PDF files, draw polygons with rounded corners

隐身守侯 提交于 2020-01-01 05:33:06
问题 What's the right tool for the job if I want to write a Python script that produces vector graphics in PDF format ? In particular, I need to draw filled polygons with rounded corners (i.e., plane figures that are composed of straight lines and circular arcs ). It seems that matplotlib makes it fairly easy to draw rectangles with rounded corners and general polygons with sharp corners. However, to draw polygons with rounded corners, it seems that I have to first compute a Bézier curve that

Merging multiple adjacent rectangles into one polygon

蓝咒 提交于 2019-12-28 10:12:07
问题 Background : I am working on a site for small shopping center, which has multiple rectangular "units" to rent. When a "shop" comes, it can rent one or multiple "units", and I'd like to generate a map consisting of shops (sans unrented units) Problem : I have a list of rectangles ( units ), defined by pairs of points – [[lefttop_x;lefttop_y];[rightbottom_x;rightbottom_y]] – and I want to merge them into polygons, so I can properly style them (which I will then render via Canvas/SVG/VML/Raphael

Merging multiple adjacent rectangles into one polygon

笑着哭i 提交于 2019-12-28 10:07:43
问题 Background : I am working on a site for small shopping center, which has multiple rectangular "units" to rent. When a "shop" comes, it can rent one or multiple "units", and I'd like to generate a map consisting of shops (sans unrented units) Problem : I have a list of rectangles ( units ), defined by pairs of points – [[lefttop_x;lefttop_y];[rightbottom_x;rightbottom_y]] – and I want to merge them into polygons, so I can properly style them (which I will then render via Canvas/SVG/VML/Raphael

Finding if point is in 3D poly in python

天涯浪子 提交于 2019-12-24 17:19:13
问题 I am trying to find out whether a point is in a 3D poly. I had used another script I found online to take care of a lot of the 2D problems using ray casting. I was wondering how this could be changed to work for 3D polygons. I'm not going to be looking at really strange polygons with a lot of concavity or holes or anything. Here is the 2D implementation in python: def point_inside_polygon(x,y,poly): n = len(poly) inside =False p1x,p1y = poly[0] for i in range(n+1): p2x,p2y = poly[i % n] if y

Generating Polygons from Image (Filled Shapes)

女生的网名这么多〃 提交于 2019-12-24 13:18:31
问题 I'm trying to generate polygons from a preprocessed world map, What i have done so far is: 1: Generated a contour map for each of the countries, it looks like this: From here i filled each of these countries with an random color like this: So far ive tried to just select a random pixel in the countour image and followed the line around until i hit the start point. This did give me a relatively good result, without about 90% accuracy on the polygons, However some countries dissapeared totally.

Accessing Coordinates in a nested geojson file to draw polygons with Google Maps API v3

混江龙づ霸主 提交于 2019-12-23 03:21:37
问题 I am having a real pain of trying to draw multiple polygons from a geojson file. Below I have pasted a sample of the geojson file and the javascript used to access it. It seems the main problem I am running into is that I cannot get into that array of coordinates nested in each record as it either returns the error that "coordinates" is undefined or that there is no method "setMap" for undefined. I have been able to return other nested aspects of a similar JSON file (this is a test file, the

Accessing Coordinates in a nested geojson file to draw polygons with Google Maps API v3

时光总嘲笑我的痴心妄想 提交于 2019-12-23 03:21:14
问题 I am having a real pain of trying to draw multiple polygons from a geojson file. Below I have pasted a sample of the geojson file and the javascript used to access it. It seems the main problem I am running into is that I cannot get into that array of coordinates nested in each record as it either returns the error that "coordinates" is undefined or that there is no method "setMap" for undefined. I have been able to return other nested aspects of a similar JSON file (this is a test file, the

Rectangles from Points using Python

假如想象 提交于 2019-12-22 05:25:19
问题 I have a text file full of points. They are separated on each line by a comma-limited (x,y) pair. eg. -43.1234,40.1234\n -43.1244,40.1244\n etc. I now need to create a polygon around each of these points. The polygon has to have a 15 kilometer buffer from the point. I don't have access to ArcGIS or any other GIS that provides this functionality for me so at this point, I am wondering if anyone has the math that will help me get started? 回答1: You want to use GDAL/OGR/OSR, which does

How to change a SpatialPointsDataFrame into SpatialPolygonsDataFrame in R to use it after in ggplot2?

▼魔方 西西 提交于 2019-12-21 05:13:09
问题 I use R to project some data flows on a world map using great circles form ggplot2. I would like to also project on my map also urban areas from: http://www.naturalearthdata.com/downloads/ These are however in a SpatialPointsDataFrame. Perhaps my question is trivial, but I don't know how to change the file into SpatialPolygons. My code goes as follows: urbanareasin <- readShapePoly("//....//ne_10m_populated_places//ne_10m_populated_places.shp") simp<-gSimplify(urbanareasin, tol=0.1)

How to add labels on top of polygons in leaflet

Deadly 提交于 2019-12-19 08:59:21
问题 I am working with the leaflet R package. I have a zoning system made of polygons and I'd like to lay their IDs on top of them. Below is an illustration (with another software) of my objective. Thanks for your suggestions! 回答1: Since there is no reproducible data, I decided to use one of my previous posts related to leaflet. There are two things you want to take away from this post: 1) you need to create a data frame containing center points of target regions, 2) you need to use