Hot answers tagged

9

You are nearly there. There is a little trick which is to use Postgres's distinct operator, which will return the first match of each combination -- as you are ordering by ST_Distance, effectively it will return the closest point from each senal to each port. SELECT DISTINCT ON (senal.id) senal.id, port.id, ST_Distance(port."GEOMETRY", senal."GEOMETRY") ...


9

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

The aproach with cross-join doesn't use indexes and requires a lot of memory. So you basically have two choices. Pre 9.3 you'd use a correlated subquery. 9.3+ you can use a LATERAL JOIN. KNN GIST with a Lateral twist Coming soon to a database near you (exact queries to follow soon)


7

One approach is to convert this to raster and then extract contours Another is to find the buffer for each point;Dissolve those buffers to get a narrow polygon;Find the center line of each dissolved polygon.


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 ...


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

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 ...


4

It doesn't matter at what longitude you are. What matters is what latitude you are. Length of 1 degree of Longitude = cosine (latitude in decimal degrees) * length of degree (miles) at equator. Convert your latitude into decimal degrees ~ 37.26383 1 degree of Longitude = ~0.79863 * 69.172 = ~ 55.2428 miles More useful information from the about.com ...


4

The radius, r, of the small circle joining all points at latitude, φ is r = R cos φ where R is the radius of the sphere. That simplifies to r = cos φ if we assume a "unit sphere" (R = 1) for convenience. --------------------- A/D | r φ / | / | / | / |a / |x / |i ...


4

I would approach this as follows: Convert your polygons into lines (by which each edge of the polygons - a line between the consequent vertices - will become a line feature in the output feature class.) After the conversion, the output lines will preserve their "parent" polygon ID. Use GP tool: Feature To Line. Take each point and then find out which line ...


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, ...


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 ...


3

Use GME available from http://www.spatialecology.com/ use the "Point distance tool" from the geoprocessing tools of ArcGIS - for proximity calculations to find the object distance in the same layer. You can specify search radius. I hope this helps..


3

Both variables are zonal means. The average distance to the nearest facility is the zonal mean of the Euclidean distance grid (based on the facilities). The average number of facilities is the zonal mean of a one-kilometer radius focal sum of the facilities grid. (This is merely a grid whose cell values count the number of facilities within each cell. ...


3

You should use the Near GP tool for that (Advanced license only). It will add two fields to your point shapefile: one for distance to the nearest coastline feature and another for the coastline feature ObjectID.


3

The near tool gives you the results in the linear unit of measurement of the layer's projection. Try choosing a different (appropriate for your dataset) projection that uses feet. Then re-run the near tool.


3

I am no expert in this but from my understanding: The OpenLayers plugin in QGIS uses the EPSG:3857 CRS which is a projected CRS on a flat surface (here's a very good post describing it). Therefore, it calculates a straight-line distance as you would on a paper map. I can't find how Google Maps calculates its distances but a common method would be to use ...


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

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

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

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

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" ...


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 ...


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 ...



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