Hot answers tagged

39

Mapperz's answer is invalid. Sinus must be calculated from latitude and NOT from longitude. So corect SQL statement is: SELECT id, ( 3959 * acos ( cos ( radians(78.3232) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(65.3234) ) + sin ( radians(78.3232) ) * sin( radians( lat ) ) ) ) AS distance FROM ...


36

The SQL statement that will find the closest 20 locations that are within a radius of 30 miles to the 78.3232, 65.3234 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 30 miles, orders the whole query by distance, and limits ...


34

Use plugin Numerical Vertex Edit (https://plugins.qgis.org/plugins/numericalVertexEdit/). Or create table with Lat/Lon/Name and save in csv, then load csv table in QGIS (Add Delimited text layer) (info gis-lab.info)


27

No Plugin Required This is possible with QGIS without extra plugins using the Advanced Digitizing panel. This tool allows entering exact coordinate values as well as constructing points at given distance and angle from other points. Note: The advanced digitizing tools are not available in geographic coordinates. Pictures taken from this excellent answer ...


27

Here's a python function that will select random features in a layer based on percent, ignoring current selection: def SelectRandomByPercent (layer, percent): #layer variable is the layer name in TOC #percent is percent as whole number (0-100) if percent > 100: print "percent is greater than 100" return if percent < 0: ...


27

The simplest way is to use the points to create the line. To do this in QGIS use the Points2One plugin. Install this plugin (available via Plugins->Manage and install plugins) and follow the dialog to create a line from your points. If you have multiple lines, then make sure your points data has a suitable ID field to identify the lines they belong to....


26

Try the 'mmqgis'-plugin. There, go to Modify -> delete duplicate geometries and select your layer.


23

It seems like you're working with Ordnance Survey Code-Point data, which is a dataset of the postal code areas in Great Britain and Northern Ireland. The "points" you're referring to are small square polygons that represent so-called "vertical streets": stacks of more than one post code, which can't be represented using "conventional" polygons (see Andy ...


22

Populated Places 1:10m (Natural Earth) Shapefile 7343 Cities Download from http://www.naturalearthdata.com/downloads/10m-cultural-vectors/ (Populated Places) Terms of Use http://www.naturalearthdata.com/about/terms-of-use/ No permission is needed to use Natural Earth. Crediting the authors is unnecessary. However, if you wish to cite the map ...


21

There is now a plugin called QChainage that does exactly what you want. You specify an interval distance and the plugin creates points along your line at the specified interval.


21

I found a way using purely Python to get the coordinates for tweets using a word filter. It doesn't seem like many people include location with their tweets. This might not be what you're after either because this is live streaming data. You can test it by putting a unique filter word and then tweeting that word from your Twitter account. You will see your ...


21

I would go the complicated way: Two Tables in a 1:n relation one table with the point location of the graves another table with the Grave-ID and person data You can build a relation between the two tables so that selecting a grave will select all person records in the person-table. The idea of having tables with fields like Person1, Person2... is ...


20

If you do not care about whether the point is a centroid or not, just use Vector -> ResearchTools -> Random Points. You may define to place a single point per each polygon in a layer. Also you may create centroids for initial polygons, delete points that do not intersect any polygon, save polygons without points as a separate layer, create random points for ...


20

In the Python console: you can use the Shapely module (as in How to create equidistant points in QGIS?) with the function point = line.interpolate(currentdistance) The new Python API of the master version (1.9) has an equivalent command (as in Generating chainage (distance) nodes in QGIS of Nathan Woodrow) point = geom.interpolate(currentdistance) or ...


20

To create polygons from points, you can also use "points to path", then "lines to polygons" tools without need to install any plugin


20

As an alternative, you could: Use the Convert Lines to Points tool from: Processing Toolbox > SAGA > Shapes - Points > Convert Lines to Points (Add points over small distances. E.g. add a point every 1m if the overall line is 100m) Use the Distance to nearest hub from: Processing Toolbox > QGIS geoalgorithms > Vector analysis tools > Distance to nearest ...


19

I was having problems with the QGIS and SAGA GUI tools mentioned in this thread (Raster values to points was failing for some reason and throwing unhelpful errors and the GRASS v.sample created a whole new layer which was not helpful). After failing with the GUI tools for a while, I tried doing this in the Field Calculator. It worked quite well and I was ...


18

I know this is old but I was looking for the same as I don't have ArcInfo for the FeatureVerticesToPoints tools. After using Search cursor solution above I went forward to simplify the code and found that using NumPy Arrays in the Data Access Module a simple and very quick script could be produced. I'm using this as a script tool. Note: The key is the ...


18

This query should do the trick: WITH line AS (SELECT your_polylinestring_id, (ST_Dump(geom)).geom AS geom FROM your_polylinestring_table), linemeasure AS (SELECT ST_AddMeasure(line.geom, 0, ST_Length(line.geom)) AS linem, generate_series(0, ST_Length(line.geom)::int, 10) AS i FROM line), geometries AS ( ...


17

Maybe I'm not understanding, but you seem to be entering Longitude Latitude coordinates (-97, 21) in degrees,into a CRS that is UTM based, and uses meters. If you're declaring this as SRID 26918, then the long/lat values must be in that CRS. If the Long/Lat values are in degrees then you will need to create the geometry as ST_SetSRID(MakePoint(...),4326) ...


16

The trick when using a table of points is to feed all the points into ST_VoronoiPolygons by using ST_Collect, which simply combines all the points into a MultiPoint, without performing any spatial operations such as would happen with ST_Union. So, for example, with a random table of points as input, you can do: WITH points(geom) AS (SELECT ...


15

The process for this seems to have changed between ArcGIS 10.0 and 10.1. I will include a sample for both. Here is the help document on reading geometries in 10.1 using arcpy: Reading Geometries 10.1 This document discusses the parameters for a Polyline geometry type: Polyline (arcpy) 10.1 import arcpy infc = arcpy.GetParameterAsText(0) # Enter for ...


15

In ArcGIS you can use Hawth's Tools to generate your points or in QGIS you can use Vector->Research Tools->Random Points or Regular Points. However, you say the points will represent windmill bases and you want to maximise production. So, personally, I would not use either of these methods. Maximising windfarm production is dependent on much more than ...


15

select (ST_Azimuth(h.vec) - ST_Azimuth(h.seg)) from ( select ST_MakeLine(cp.p, point.geom) vec, ST_MakeLine(cp.p, ST_LineInterpolatePoint( line.geom, ST_LineLocatePoint(line.geom, cp.p) * 1.01) ) seg from ( select ST_ClosestPoint(line.geom, point....


14

The data as downloaded contain some frank locational errors, so the first thing to do is limit the coordinates to reasonable values: data.df <- read.csv("f:/temp/All_Africa_1997-2011.csv", header=TRUE, sep=",",row.names=NULL) data.df <- subset(data.df, subset=(LONGITUDE >= -180 & LATITUDE >= -90)) Computing grid cell coordinates and ...


14

If you want to interactivelly change your points coordinates, one by one, I believe you can do what you want by using the Numerical Vertex Edit Plugin. I can install it in Plugins > Fetch Python Plugins and search it by its name. After installing you will notice a new icon on you digitalizing toolbar like this . To make it active you must be editing a ...


14

I have exactly the same use case at work, so this is what I have come up with: Solution 1 (ellipse) This looks fairly regular, but is the least precise generally, IMO. Use the ellipse marker symbology with the following data-defined overrides and change the units from Millimeter to Map Unit (essential!): Symbol width: "E" + "W" Symbol ...


13

The NNJoin Plugin should do the job. For each feature of the input layer it adds all the attributes of the nearest feature in the join layer and also adds a distance attribute with the distance to this feature.


13

EDIT : answer by @Kampau Ocu : "point on surface is already within QGIS3 Processing Toolbox" You can also use the plugin RealCentroid that does just what you're looking for : RealCentroids plugin creates a point shape file with internal points of a polygon shape, similar to PostGIS (GEOS) ST_PointOnSurface. The point will be inside the polygon in all ...


13

Posted a code snippet(tested in python console) that doest the below Use QgsSpatialIndex to find the nearest line feature to a point Find the nearest point on this line to the point. I used shapely package as a shortcut for this. I found the QGis methods for this as insufficient(or most probably i do not understand them properly) Added rubberbands to the ...


Only top voted, non community-wiki answers of a minimum length are eligible