polygon

ggplot: How to produce a gradient fill within a geom_polygon

大城市里の小女人 提交于 2019-11-29 10:05:06
This should be fairly easy but I can't find my way thru. tri_fill <- structure( list(x= c(0.75, 0.75, 2.25, 3.25), y = c(40, 43, 43, 40)), .Names = c("x", "y"), row.names = c(NA, -4L), class = "data.frame",Integrated=NA, Related=NA) # install.packages("ggplot2", dependencies = TRUE) require(ggplot2) ggplot(data=tri_fill,aes(x=x, y=y))+ geom_polygon() + scale_fill_gradient(limits=c(1, 4), low = "lightgrey", high = "red") What I want is a gradient along the x-axis, but with the above I only get a legend with a gradient and the polygon with solid fill. Here is a possible solution for when you

map city/zipcode polygons using google maps

主宰稳场 提交于 2019-11-29 09:54:52
问题 I am looking for a javascript library that supports the ability to pass a zipcode or city as a parameter, and get a list of x,y coordinates to draw a polygon using google maps? Does this exist? Does the google maps API support such queries? I am looking for an array of coordinates similar to those that google uses to draw maps on a google query: 回答1: Google Maps API doesn't support that kind of solution. There are a couple other places from which you can get the coordinates, though: Flickr

how to get coordinates of a polygon in OpenLayers

自古美人都是妖i 提交于 2019-11-29 09:36:49
问题 I have been looking for how to determine coordinates of the points which consist a polygon(feature) in OpenLayers. Let's say I have created a polygon like the one in this example. I need to know the points which consist the polygon, so I can save them somewhere. I bet it is an easy one. I just couldn't find anything, probably I don't know what I should search for. Thanks in advance. 回答1: Found it finally! vectors.features[0].geometry.getVertices() 来源: https://stackoverflow.com/questions

Calculate the area of a polygon drawn on google maps in an Android application

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 08:50:26
I would like to calculate the are of a polygon drawn in a map fragment for a college project. This is how I draw my polygon. @Override public void onMapClick(LatLng point) { //tvLocInfo.setText("New marker added@" + point.toString()); map.addMarker(new MarkerOptions().position(point).draggable(true).title(point.toString())); markerClicked = false; } @Override public void onMapLongClick(LatLng point) { //tvLocInfo.setText("New marker added@" + point.toString()); map.clear(); } @Override public boolean onMarkerClick(Marker marker) { if(markerClicked){ if(polygon != null){ polygon.remove();

Convert a Google Maps polygon path to an SVG path

最后都变了- 提交于 2019-11-29 08:50:21
When a user has drawn a polygon in Google Maps using the built in Drawing Manager I save the polygon path. I want to convert this polygon path to an SVG path so that I can reproduce the shape of the polygon drawn easily, without requiring lots of additional map loads and calls to the Google Maps API. I'm sure it's just some fairly trivial mathematics but can't work out how to do it. Do I need to create a bounding box around the points and translate it to LatLng 0, 0 before scaling it down or can I do something simpler using just the LatLng coordinates of each point? I've found lots of

Intersection of two convex polygons

耗尽温柔 提交于 2019-11-29 08:41:17
问题 I have two convex polygons. Polygons are implemented as cyclic lists of their vertices. How to find an intersection of this two polygons? 回答1: For each edge V1-V2 in the first polygon, Let H := Half-plane tangenting V1-V2, with the remaining vertices on the "inside". Let C := New empty polygon. For each edge V3-V4 in the second polygon, Let X := The intersection between V3-V4 and H. If V3 inside H, and V4 is outside H then, Add V3 to C. Add X to C. Else if both V3 and V4 lies outside H then,

Find the closest point on polygon to user location

让人想犯罪 __ 提交于 2019-11-29 08:15:20
I have an app that find the shortest distance between my user to a polygon. I want to convert the polygon to Geofence to check the distance between the user to the area to give mor accurate information to the user. how can I do that? this is the MapsActivity public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, LocationListener, MinimumDistanceTask.GetMinimumDistanceListener { private GoogleMap mMap; private LocationManager manager; private double lat, lng; private KmlLayer layer; private LatLng latLngTest; private boolean contains = false; private ArrayList<LatLng>

different coloured polygon overlays

你。 提交于 2019-11-29 08:13:12
is it possible to create different coloured polygons on a map view using the following method? -(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id )overlay{ say if i had 2 polygons could i set one to red and the other to yellow? One way is to use the title property to tell one polygon from another. When adding the polygons, set their title accordingly: pone.title = @"one"; [mapView addOverlay:pone]; pother.title = @"other"; [mapView addOverlay:pother]; Then in viewForOverlay , you can set the color based on title: - (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id

How to do freehand drawing in Google Maps on iOS?

孤街浪徒 提交于 2019-11-29 07:37:56
In drawing application we can identify when the user is starting to draw and moving the finger to make a line/shape. I'm trying to do the same on a map, how can I do this? Basic steps will involve: 1) Add a overlay view whenever user starts to draw. lazy var canvasView:CanvasView = { var overlayView = CanvasView(frame: self.googleMapView.frame) overlayView.isUserInteractionEnabled = true overlayView.delegate = self return overlayView }() @IBAction func drawActn(_ sender: AnyObject?) { self.coordinates.removeAll() self.view.addSubview(canvasView) let origImage = UIImage(named: "pen") let

find the smallest containing convex polygon with a given number of points

别说谁变了你拦得住时间么 提交于 2019-11-29 05:54:37
问题 given a convex polgyon and a number N, how do I find the smallest polygon that contains every point from the original polygon has exactly N corner points For example, suppose I have a set of points and compute the convex hull for them (green). Now I want to find the smallest quadrangle that contains all the points (red) It is easy to see that any other polygon with 4 corners would either be bigger or fail to contain all the points. But how do I find this polygon in the general case? EDIT: