# Tag Info

10

You could use the Group Stats plugin from Plugins > Manage and Install Plugins. This calculates various data statistics for your attributes such as finding the minimum value in a group. I made an example of attributes from the data you gave: Then from the Group Stats interface, select and drag the toid field from the list into the Rows window; and repeat ...

7

You can do it via the geography type, using a geography index, or via the geometry type with some math to adjust for distortions in mercator. With geography: CREATE INDEX gb1900_geog_idx ON gb1900 USING GIST (geography(the_geom)); CREATE TABLE newtable AS WITH c AS ( SELECT a.cartodb_id, count(*) FROM gb1900 a, gb1900 b WHERE ST_DWithin(...

6

Your coordinates are out of order. If you reverse the order of coordinates in the first query, postgis says: 708.55982691. In postgis it's lon, lat, not lat, lon.

5

You could have a look at the Route360°-API, a pretty simple but powerful JS library which you can use with Leaflet (or even Google maps if you like). It adds travel time polygons to your map for the travel times you require (e.g. 10, 20, 60 minutes) and for the following travel modes: walk, bike, car, transit. There are quite a few examples on how to use ...

5

Assuming you are using geography type which I am guessing from geog name, query to find all census blocks within 1609 meters ~ 1 mile) of parcel denoted by key '12345'. SELECT census_blocks.* FROM census_blocks INNER JOIN parcels ON ST_DWithin(census_blocks.geog, parcels.geog, 1609) WHERE parcels.parcel_id = '12345';

5

Distance calculations that assume shortest distance on the Earth will always be faster than geometry because geometry can be in any projection, and there's no way generally to know that the shortest path in that projection is the 'shortest path' and so you need to go to ellipsoid calcs and potentially insert more vertices for the curvature from the source to ...

5

There are several linear referencing functions that can be used to reference subsets of LineStrings, which can be converted to a geography and get the length of the geodesic with ST_Length. For example, get the distance along line that are near points pta and ptb: SELECT ST_Length(ST_LineSubstring( line, ST_LineLocatePoint(line, pta), ...

5

Because the principles and the algorithms are different (look at Geographical distance) Shapely use the euclidean distance in a cartesian plane and the shortest distance between two points in a plane is a straight line which contains the two points. import numpy as np print np.linalg.norm(np.array(pt_user) - np.array(pt_store)) 110.02637304449682 # ...

4

If you have full control over the algorithm and implementation, for a coarse approximation you could probably Get the coordinates of some points on your polylines in equal distance from the respective starting point Approximate a straight line through your points of each polyline (https://en.wikipedia.org/wiki/Simple_linear_regression) Get the distance ...

4

By using PyQGIS this code works: from math import sqrt layer = iface.activeLayer() features = layer.getFeatures() points = [] for feature in features: geom = feature.geometry().asPoint() points.append(geom) n = len(points) for i in range(n-1): for j in range(n): if i < j: print i, j, sqrt(points[i].sqrDist(points[j]))...

4

If you want to take advantage of the former code you can do that: from math import sqrt import itertools layer = iface.activeLayer() features = layer.getFeatures() lines = [feature.geometry().asPolyline() for feature in features] k = 0 for points in lines: n = len(points) list = range(n) print "line" + str(k) + ", " + str(n) + " points" ...

4

Try something like this. Use the Generate Near Table analysis function. This gets you the distance to the closest line on the Polygon as in your diagram. Join this information back to the the original points file. Build the new point based on the angle and the distance you now have in the original point layer. Something like this in the field calculator ...

4

It depends on your accuracy needs. Fortunately, since you only have to make a discrete decision--which country is closest?--you only need reasonably good relative accuracy in the directions towards all the coastlines. Although a custom projection could be designed to give very high accuracy in those locations and in those directions, that would require a ...

4

If you inverse the coordinates, it does not work (geopy uses (latitude,longitude) in the WGS84 crs) dublin = (53.33306,-6.24889) liverpool = ( 53.41058,-2.97794) print distance(dublin, liverpool).km 217.863019038 print(vincenty(dublin, liverpool).kilometers) 217.863019038 print(great_circle(dublin, liverpool).kilometers) 217.211596704 GEOS (...

4

If you're happy with the characteristics of your projection, you should just use ST_Distance(geometry, geometry). In your example you seem to be in UTM, which is a pretty good projection, so why not? It's much much less CPU intensive than the geodetic functions ST_Distance(geography, geography). (Note that ST_Distance_Spheroid() just calls into the same ...

4

You want to use ST_DWithin() which takes advantage of indexing SELECT * FROM adresse WHERE ST_DWithin(latlong::geography, ST_SetSRID(ST_Point(16.520, 47.846), 4326)::geography, 200) ORDER BY ST_Distance(latlong::geography, ST_SetSRID(ST_Point(16.520, 47.846), 4326)::geography); See also http://postgis.net/2013/08/26/tip_ST_DWithin/

3

So, we've ended up changing tact and moving to spatialite and seem to have managed to do it with an SQL query, including the geometry field which means I can add it as a new layer: Select Distinct T1.toid As TOID1, Min(T1.Hubdist) As MinDIST, T1.ID, T1.geometry From [Hub Distance] T1 Inner Join (Select T2.toid As TOID2, ...

3

The length of degree in north-south is about the same so you could use 1/110574 degree/meter as a factor. However, the farther to south or north you go the bigger the error is in east-west direction. For example, take these two shapes which have a 1 degree buffer in EPSG:4326 transformed into EPSG:32630 (UTM zone 30N). First one is from 40°N and the second ...

3

you can't really convert convert distances in degrees into meters as the size of a degree varies as you approach the poles. convert your locations into a projected coordinate system, then calculate your distances.

3

So your GPS coordinates are far apart? If they are close - eg. short segments along a road, then "straight line" is good enough. There is an open source extension for PostGIS that can calculate road distances. It is called pgRouting. You will also need to create a road database - typically OpenStreetMaps is used.

3

Linear reference should do the job, but can be bulky. This is why I am using this script: # Import arcpy module import arcpy, os, traceback, sys,time from arcpy import env env.overwriteOutput = True infc = arcpy.GetParameterAsText(0) routeid = arcpy.GetParameterAsText(1) outfc=arcpy.GetParameterAsText(2) fields = [f for f in arcpy.ListFields(infc)] ...

3

The following approach requires you to have an Advance license: Convert your polygons to lines using the Feature To Line tool Identify the distance from your centroid point to the line using the Generate Near Table tool These two steps can be wrapped up in a model.

3

If you are working with GRASS, then you can use the module v.distance. When you import the 2kmX2km grid into grass, it automatically creates centroids for each grid cell (that's how the vector design in GRASS works). So you would first add a column in the grids table to hold the distance value, then run v.distance to update that column: (Assuming two GRASS ...

3

I think this requires 2 tools, both of which can be accessed from the Processing Toolbox: GRASS - v.split.length SAGA - Convert Polygon/Line Vertices to Points

3

The video explains it very well. If you take the edge in question and segmentize it SELECT st_asewkt( st_segmentize(geog,10000)) FROM ST_GeographyFromText('LINESTRING (70 -39,71 -39)') geog you going to have the following : the point is the the point you are asking about. The line represents the edge. North is up. (distance measurement done by hand,...

3

You can find these points using ST_DumpPoints (docs) combined with the lag and lead window functions. First, we can set up some test data: CREATE TEMPORARY TABLE test (geom geometry); INSERT INTO test VALUES ('LINESTRING (1 1, 2 2, 3 3, 4 4, 5 5)'); Then, we can use ST_DumpPoints to get the coordinates in sequence: SELECT ST_DumpPoints(geom) AS dump ...

3

Using a neighbourhood matrix with adjacent gives you the cell numbers around a given cell, so you could extract values from increasing neighbourhoods until a threshold is reached. Function to build a neighbourhood matrix to centre on a given point. ##' @param n size of neighbourhood matrix 3,5,7,... nmatrix <- function(n) { ## n must be odd and >...

3

One way would be to use ICurve QueryPointAndDistance to and get the DistanceAlongCurve value for your 'B' point. Then call ICurve.GetSubcurve twice (with the DistanceAlongCurve + 2 and DistanceAlongCurve - 2) and the fromDistance parameter as 0. And the asRatio as false. The "To" points of the resulting subcurves would be your 'A' and 'C'. http://...

3

WGS 84 and ETRS 89 are two geographic coordinate systems (Lat/long). With those coordinate system, you will measure distances on the surface of the ellipsoid. WGS84 and ETRS 89 use almost identical spheroid (see below), so in most cases you will not see any difference between the 2. You are projecting your data in Universal Transverse Mercator zone 35 (...

3

Your first two equations choose a random distance and a random angle. Your random numbers will range from [0,1] uniformly. You can look at the rings below as limiting the choices to 0.1, 0.2, etc. If you don't alter the possible distribution of distances (left), there are many more chances to be quite close to the center. The probabilities are much more ...

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