Tag Info

Hot answers tagged

19

EDIT Oh, so many typos in one post must be some sort of record. Table names was messed up, I hope it is better now. I also realized on the way home that something is wrong here. ST_DWithin was faster in my test than ST_Intersects. That is surprising, especially since the prepared geometry algorithm is supposed to kick in on cases like this. I think there ...


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


13

If you're looking for a PostGIS function that will tell you a point that's inside your polygon then the ST_PointOnSurface function may give you what you need. SELECT ST_AsText(ST_PointOnSurface('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'::geometry)); st_astext ---------------- POINT(2.5 2.5) (1 row)


12

If "fastest" includes the amount of your time that is spent, the solution will depend on what software you are comfortable with and can use expeditiously. The following remarks consequently focus on ideas for achieving the fastest possible computing times. If you use a canned program, almost surely the best you can do is pre-process the polygons to set up ...


10

Short answer: No. With this type of UPDATE query, we are updating each row in locations ("Seq Scan"), and the GiST index on the_geom in regions is sufficient in helping limit rows for the ST_Within condition to pair-up the right row from regions. Longer answer: The magic to figuring this out is to compare what you get from explain query. From pgAdmin III, ...


9

For your specific question, you should be able to use point.in.polygon (docs) or overlay (vignette) to perform the analysis. A spatial predicate language isn't trivial to implement, and all the examples you mentioned boil down to ports or wrappers of JTS at some point. There is a pre-alpha release of rgeos, a recent Google SOC entry which provides access ...


8

Yet another option, this is more of a theory and programmatic one, using arcpy. A polygon can consist not only of a single outer ring with a single inner donut hole -- they can be nested to an arbitrary number of levels. Consider the following: A topologically correct polygon's rings are ordered according to their containment relationship (source). ...


8

Create 2 new columns (x and y) type real. In field calculator use option update existing field and execute following expressions: $x (for x column) and $y (for y column). Actually you can create new columns in field calculator directly using create new column option. Now you can export your layer as CSV (save layer as) and work with it in Excell or whatever ...


8

Here is an example using a SpatialGrid object: ### read shapefile library("rgdal") shp <- readOGR("nybb_13a", "nybb") proj4string(shp) # units us-ft # [1] "+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333 # +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +datum=NAD83 # +units=us-ft +no_defs +ellps=GRS80 +towgs84=0,0,0" ### define ...


7

If you had the polygon bounding boxes stored in something like a quad tree then you could use that to quickly determine which polygons to check. At the very minimum you could just see if the point is inside each polygon bounding box as opposed to doing a full point in polygon for each polygon. Personally I'd setup a web service which would cache the ...


7

Another option, without needing the function update points set country = t1.country from ( select points.oid, countries.name as country from countries INNER JOIN points on st_contains(countries.wkb_geometry,points.wkb_geometry) ) t1 where t1.oid = points.oid I suspect (although I haven't tested) that this will be faster than using a nested ...


7

This should do what you need: A select query: SELECT polygons.id, Count(*) FROM points JOIN polygons ON polygons.ogr_geometry.STContains(points.ogr_geometry) = 1 GROUP BY polygons.id With an update: UPDATE polygons SET [countcolumn] = counts.pointcount FROM polygons JOIN ( SELECT polygons.id, Count(*) FROM points JOIN polygons ON ...


6

1) Select your polygon of interest - you can do this manually or with one of the selection tools. 2) Select your 'marginal' points using the Select By Attributes tool with the Method drop-down set to 'Add to current selection'. You will now have a selected polygon in one layer and selected points in another layer. 3) Use the Select By Location tool to ...


5

As with almost all such questions, the optimal approach depends on the "use cases" and how the features are represented. The use cases are typically distinguished by (a) whether there are many or few objects in each layer and (b) whether either (or both) layers allow for precomputing some data structures; that is, whether one or both of them is sufficiently ...


5

I suspect it's because the underlying GEOS library only work in Cartesian space rather than spherical, so you'll have to subtract 360 from any longitudinal coordinate greater than 180, which makes 359 == -1. Of course, you'll still have problems with features crossing the anti-meridian (i.e. +- 180 degrees longitude), but you can easily detect that and not ...


5

For my part, I would probably load CSV data into a shp file and then write a python script using shapefile and shapely to get the containing polygon id and update the field value. I don't know whether geotools and JTS is faster than shapefile/shapely ... Have no time to test it! edit : By the way, the csv conversion to shapefile format is probably not ...


4

do you have to use that mask or could you load a shapefile (from say Natural Earth) and then do your look ups against those polygons? If you can then GeoTools (http://docs.geotools.org/stable/userguide/examples/) should be able to do this quite easily. In fact with a little more work you should be able to export the landmask from netCDF into a GeoTiff and ...


4

I ended up converting the polygons to a raster and sampling it at the point positions. Since my polygons didn't overlap and high accuracy wasn't necessary (polygons represented land-use classes and their borders were considered rather uncertain anyway) this was the most time-efficient solution I could come up with.


4

There's probably an easier way to do it but this is what I do. //layer is what layer you are checking ESRI.ArcGIS.Carto.IIdentify identify1 = layer as IIdentify; //idGeo is IGeometry you want to query -in your case a point, but I'm using a square here IArray array = identify1.Identify(idGeo); if (array != null) { object obj = ...


4

If you're using SQL Server 2008, you should look into the built-in spatial functionalities - I think you find them quite snappy. Look at the STIntersects() method in particular. Everything you need to do could be easily wrapped up in a stored procedure - the testing of the geometries against one another (is this point in this polygon) followed by setting the ...


4

Your task is slightly more complicated than you would expect. You will need to create a separate polygon shapefile/featureclass. I would approach the problem as follows: Add a new shapefile or feature class to your project (right click on folder/feature dataset > new Shapefile/Feature Class... > feature type "Polygon"). Make sure to define your ...


4

OK...I did a little bit of hacking and found that a SQL FUNCTION get me most of the way there. Anyone have any thoughts on taking this to the bridge? CREATE OR REPLACE FUNCTION getcountry ( country_geom geometry ) RETURNS TABLE(country text) AS $$ SELECT b.name as country FROM geonames d, world_borders b WHERE ...


4

I'd go the Open Layers plugin; fetch it, and you can then even add whatever dynamic layer to your map and export. *Before doing so, ensure you have your project CRS(EPSG) set to WGS84, and that 'on the fly' CRS transformation is enabled under your Project Properties settings. Hope this helps.


4

If we examine your polygon: polygon = shapefile_record['geometry'] print polygon.bounds (77.84476181915733, 30.711096140487314, 78.59476181915738, 31.28199614048725) From Shapely manual, object.bounds: Returns a (minx, miny, maxx, maxy) tuple (float values) that bounds the object. Here minx = 77.84476181915733, miny = 30.711096140487314 = here, min ...


4

Would be more efficient with EXISTS I think since it can stop after first positive. Though Martin's answer should work as well SELECT boundary.* FROM boundary WHERE EXISTS (SELECT location.geom FROM location WHERE ST_Intersects(boundary.geom,location.geom) );


3

Probably the easiest way is with PostGIS. There are some tutorials on the internet how to import csv/txt point data into PostGIS. Link1 I am not sure about performance of point-in-polygon searches in PostGIS; it should be faster than ArcGIS. GIST spatial index that PostGIS uses is pretty fast. Link2 Link3 You could also test MongoDB geospatial index. But ...


3

Are you looking for the centroid? You could use iArea:Centroid to obtain the centroid of the geometry (may not fall inside of the area if the geometry Or you could use iArea:LabelPoint which is similar to centroid but guaranteed to fall inside of the area of the geometry. However, I am pretty sure that the "X" you are referring to is obtained from the ...


3

As Peter Krebs has suggested on mouse down use IDisplayTransformation.ToMapPoint to assign the XY info to a point graphic. You can then use that graphic as a selector against your polygon layer. public override void OnMouseDown(int Button, int Shift, System.Int32 X, System.Int32 Y) { //MyBase.OnMouseDown(Button, Shift, X, Y) try { ...


3

Here is an R solution, intended to function as pseudocode for implementation on any appropriate platform (C++, Python, etc) and to be a working prototype. It begins with a function to compute the mean and SD distances of an array of points: # # Compute distance statistics for points (x,y). # dist.stats <- function(x,y) { # # Compute all ...


3

Use Spatialite. Download the GUI. You can open both the Shapefile and CSV as virtual tables. This means that you don't actually import them into the database but they appear as tables and you can quicky join and query them any way you like.



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