polygons

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

人盡茶涼 提交于 2019-12-03 15:45:46
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) urbanareas<-ggplot2:::fortify(simp) I tried also: urbanareas<-fortify.SpatialPolygonsDataFrame(simp) and:

How do I Add and Remove Polygons on Google Maps v3?

随声附和 提交于 2019-12-03 10:36:49
I'm trying to show and remove polygons onto a Google Map, using v3 of the API. In my JavaScript, I've already got an MVCArray of some custom Lat-Longs. I'm trying to figure out how to add these polygons and then, based upon some other JavaScript event or user action, such as a click on a polygon (that has been rendered), that polygon will be removed. Can someone help? Any code or links to examples? I'm struggling to find some examples. Most of them usually go to some v2 code. In the API docs, there are a couple of simple examples of adding a polygon to a map . Here's the initialize() function

Initializing Half-edge data structure from vertices

▼魔方 西西 提交于 2019-12-03 04:17:27
问题 I'm working on implementing various subdivision algorithms (such as catmull-clark); to do this efficiently requires a good way to store information about a grid of tesselated polygons. I implemented the half-edge data structure as outlined by flipcode, but now I'm not sure how to populate the data structure from vertices! My initial attempt was to create vertices group vertices into faces sort vertices within faces (using their angle relative to the centroid) for each face, grab the first

Google Maps API - different map style for polygon

回眸只為那壹抹淺笑 提交于 2019-12-02 07:49:30
问题 I want to achieve the effect similar to what is presented here: inside Android google map. The polygon should have a different map style (json file) than the rest of the map. Is there a way of doing that? I would even accept having two different maps (one under the other) and cutting the polygon out of the top map. Would that be possible? 回答1: That effect is possible with Polygon.setHoles() or PolygonOptions.addHole() methods. You should create gray transparent polygon for all map (from -90

C# clip linesegment with clipper library

早过忘川 提交于 2019-12-01 20:28:12
I am using clipper for performing a bunch of operations on polygons which represent the outlines of objects in my program. The thing is, I now want to clip a grid of line segments to fill these outlines but I am struggling to do this with Clipper. At the moment I am converting my lines to rectangles with a thickness of 2 units which I then do an intersection operation with and then finally I need to revert the new polygons back to line segments. This is quite inefficient though and produces quite a few errors. Can this be done with Clipper, if not is there something else that I can use or do I

How to add labels on top of polygons in leaflet

别来无恙 提交于 2019-12-01 07:31:37
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! 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 addLabelOnlyMarkers() . You can achieve the first thing using gCentroid() . I added row names of the polygon data set (UK)

Changing Leaflet map according to input without redrawing (multiple polygons)

谁都会走 提交于 2019-11-30 16:21:44
cannot fix my problem for MULTIPLE filters/polygons. Currently my code works, but very slow, I do not use observe(), reactive(), and LeafletProxy() , because I stumbled. I obviously checked this answer Changing Leaflet map according to input without redrawing and this one Making Shiny UI Adjustments Without Redrawing Leaflet Maps and leaflet tutorial Using Leaflet with Shiny In my case I have four filters and do not quite understand how to combine them together and make the map fast. My sample data: Country Client Channel Status Country 1 Client 1 Agent network Launched Country 2 Client 2

draw a smooth polygon around data points in a scatter plot, in matplotlib

别说谁变了你拦得住时间么 提交于 2019-11-30 14:54:30
I have a bunch of cross plots with two sets of data and have been looking for a matploltib way of highlighting their plotted regions with smoothed polygon outlines. At the moment i just use Adobe Illustrator and amend saved plot, but this is not ideal. Example: I'd be grateful for any pointers/links to examples. Cheers Pablo Here, you have an example. I was written the main ideas, but obviously, you could do it better. A short explanations: 1) You need to compute the convex-hull ( http://en.wikipedia.org/wiki/Convex_hull ) 2) With the hull, you could scale it to keep all your data inside. 3)

Check if Polygon is Self-Intersecting

心已入冬 提交于 2019-11-30 12:42:03
问题 I have a System.Windows.Shapes.Polygon object, whose layout is determined completely by a series of Points. I need to determine if this Polygon is self intersecting; i.e., if any of the sides of the polygon intersect any of the other sides at a point which is not a vertex. Is there an easy/fast way to compute this? 回答1: Easy, slow, low memory footprint : compare each segment against all others and check for intersections. Complexity O(n 2 ) . Slightly faster, medium memory footprint (modified

How to fill a polygon with a custom hatch in matplotlib?

一世执手 提交于 2019-11-30 09:09:37
I'm using python and matplotlib to create several closed polygons. I then need to fill them with a hatch, which can be done through set_hatch. http://matplotlib.org/api/artist_api.html#matplotlib.patches.Patch.set_hatch http://matplotlib.org/examples/pylab_examples/hatch_demo.html Unfortunately I am working with greyscale images, and I need more hatches than provided by default - I would prefer to provide a bitmap (or some similar image) which could be tiled instead of using these hatches with varying densities. I am open to other python libraries (pyglet, pygame, PIL, etc) however I would