how to get coordinates of a polygon in OpenLayers - geometry

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.

Found it finally!
vectors.features[0].geometry.getVertices()

Related

How to extract point coordinates from VTK Points

I use a library that gives me at the end the vtkpoints. Now I would like to extract points
from them. But all the method available from VTKPoints require point id, which i do not know.
Is there a way of doing it?
I can't offer a definitive answer, since the VTKPoints documentation doesn't discuss the values of the point ids and I don't have any experience with this. However, all of the examples I have seen just use integers in the range [0..NumberOfPoints-1] as the point ids, so it would seem that what you are doing is perfectly reasonable (note, however, that your comment I am using the indexes: 0..NumberOfPoints should be 0..NumberOfPoints-1).
The points are definitely just stored in a vector-like container with sequential indexing from 0 to GetNumberOfPoints()-1.

How can I select layer by location AND attributes in ArcMap?

I have a dataset (i.e. a shapefile) containing spatial location data (coordinates) and elevation data as well as other attribute fields.
I want to select points which have at least 200m vertical separation (i.e. are at least 200m apart on the z-axis) AND are within 3km of each other.
The aim is to create a new shapefile with all points that have this relationship with 1 or more other points.
Im sure there is a solution to this problem (maybe not using arcmap at all?) but i just cant find it. any help would be greatly appreciated.
Chris
You are going to have much better luck asking this question in gis.stackexchange.com. Many more ESRI users/programmers there. As a matter of fact I bet you find your solution there without having to ask the question.
You can run the ArcGIS Near tool on all the points.
Then select by attribute points with Z values of >200m and distance values of <3000m.

how to calculate geographical coordinates / which geo system is this?

I have a pair of geo coordinates I don't understand. Does anybody know this coordinate system and how to translate them to longitude and latitude in degrees?
Long. 7662.251 West, Lat. 9144.590 North
Has to be a position in Honduras (13- 16°N and 83-89° W)
You really need to investigate the source of the data, files, print outs, local gandolphs etc. Even if someone can find something with a stab in the dark it's likely to be wrong in some tiny detail. Where did the pair of coordinates come from? A text file? An email? Were there any auxiliary files? With the same file name, but different extension? In the same folder? Attached to the email? Who gave it to you? What sort of computer do they use? Are they alive? Etc.
There's simply not enough information in this question to answer it - tell us at least how you know that they are "geo coordinates" - how do you know that they must be in the Honduras?
Unfortunately this level of cultural metadata is quite often about the best we have. As a massive stab in the dark they might be projected coordinates in km, rather than metres - but they could be in feet - or anything, there's really only educated guesses that can improve on this as it stands.
If it's not one of the common ones, such as UTM, have a search on the epsg registry for coordinate systems for Honduras:
http://www.epsg-registry.org/
and see if any work out. Would be a lot easier if you have any more coordinate pairs that are also in Honduras, because then we can work out an approximate scale.
I'll have a play and see if one of the UTM zones works out...

Point in Polygon check with SVG and JavaScript?

I have a map that I converted from a raster graphic into an SVG file by converting the differently coloured areas into paths.
I know how to do a basic point-in-polygon check given an array of edges, but the svg:path elements represent multiple polygons as well as masks (to account for seas etc) and extracting that information by parsing the d attribute seems rather heavy-handed.
Is there a JS library that allows me to simplify that check? I basically want to create random points and then check whether they are on land (i.e. inside the polygons) or water (i.e. outside).
As SVG elements seem to allow for mouse event handling, I would think that this shouldn't be much of a problem (i.e. if you can tell whether the mouse pointer is on top of an element, you are already solving the point-in-polygon problem).
EDIT: Complicating the matter a bit, I should mention that the svg:path elements seem to be based on curves rather than lines, so just parsing the d attribute to create an array of edges doesn't seem to be an option.
As the elements can take a fill attribute, a ghetto approach of rendering the SVG on a canvas and then finding the colour value of the pixel at the given point could work, but that seems like a really, really awful way to do it.
The answers on Hit-testing SVG shapes? may help you in this quest. There are issues with missing browser support, but you could perhaps use svgroot.checkIntersection to hit test a small (perhaps even 0 width/height would work?) rectangle within your polygon shape.
The approach I suggested as a last resort seems to be the easiest solution for this problem.
I found a nice JS library that makes it easy to render SVG on a canvas. With the SVG rendered, all it takes is a call to the 2D context's getImageData method for a 1x1 region at the point you want to check. I guess it helps to create a copy of the SVG with colour coding to make the check easier if your SVG is more complex than the one I'm using (you'll have to check the RGBA value byte-by-byte).
This feels terribly hackish as you're actually inspecting the pixels of a raster image, but the performance seems to be decent enough and the colour checks can be written in a way that allows for impurities (e.g. near the edges).
I guess if you want relative coordinates you could try creating a 1-to-1 sized canvas and then divide the pixel coordinates by the canvas dimensions.
If somebody comes up with a better answer, I'll accept it instead. Until then, this one serves as a placeholder in case someone comes here with the same problem looking for an easy solution.

Identify the plot in this image

I'm not math savvy, but this Mathematica plot caught my eye and I was hoping you could help me identify it.
I've searched the various functions and keywords found in the pictured code, but none of the results suggested anything specific to me about whatever algorithm is at work in this plot.
Sorry about the quality, it's a screen capture of a video
Looks like a Voronoi Diagram to me.
As others have noted, you're looking at a Voronoi diagram generated by Mathematica. You can see the Mathematica expression being used, and the key function is ListDensityPlot.
If you follow the latter link and open the "Neat Examples" section you'll see another Voronoi diagram. The key parameter there is InterpolationOrder→0.
Except for the two dots in the light-purple area (third from top left), one of which might be a video artifact, every coloured area has a single dot, and points in the field appear (both by looking at the diagram and guessing what the code means) to be coloured according to which of the dots they are closest to.
Which would make it, as #Moron has said, a Voronoi diagram.
True. Voronoi Diagrams can build that sort of "image".
Look for Voronoi Diagrams or Thiessen Polygons.

Resources