Tag Info

33

Yes, there is an analytical solution for this problem. The algorithm you are looking for is known in polygon generalisation as "smallest surrounding rectangle". The algorithm you describe is fine but in order to solve the problems you have listed, you can use the fact that the orientation of the MAR is the same as the one of one of the edges of the point ...

29

To supplement @julien's great solution, here is a working implementation in R, which could serve as pseudocode to guide any GIS-specific implementation (or be applied directly in R, of course). Input is an array of point coordinates. Output (the value of mbr) is an array of the vertices of the minimum bounding rectangle (with the first one repeated to ...

26

For the osmosis docs, I see the command option: --bounding-box top=49.5138 left=10.9351 bottom=49.3866 right=11.201 for PostGIS you can use ST_MakeEnvelope(left, bottom, right, top, srid) to build a bounding box, then the && bounding box operator to find where the bounding boxes intersect: SELECT * FROM mytable WHERE mytable.geom && ...

17

ST_Extent should do the trick. ST_Extent — an aggregate function that returns the bounding box that bounds rows of geometries. Applied like this: SELECT ST_Extent(the_geom) as table_extent FROM your_table;

15

WGS-what? WGS-84? Depending on what accuracy you need, you may need to know a lot more information - my guess is that's why you've been down voted, though no-one bothered to leave a comment saying why. Here are two ways: Inaccurate, but probably 'good enough' One degree of latitude is approximately 10001.965729/90 kilometres (distance from the equator ...

8

As @underdark post, st_extent will do the job, but be aware that it will not return a geometry. If you need a geometry type you should use something like SELECT ST_SetSRID(ST_Extent(the_geom),THE_SRID) as table_extent FROM your_table; Also if what you need is get the bounding box of each of the rows i think that you can use this sentence: SELECT ...

8

Generally to calculate the area of a bbox in a projected coordinate system since it's a (big) rectangle you can use the area formula : area = (sw_longitude - ne_longitude) * (sw_latitude - ne_latitude) Depending now on your spatial location (ie you're in a projected crs) the above formula will give you square mapunits (km^2, m^2 whatever). In case ...

7

SELECT * FROM myTable WHERE ST_Within(the_geom, GeometryFromText ('POLYGON((75 20,80 30,90 22,85 10,75 20))', 4326)) <-- replace coordinates as necessary

7

I think it will be something like this: The bounding box in PostGIS is created by ST_GeomFromText('POLYGON((ulx uly, urx ury, llx llr, lrx lry, ulx uly))', <srid>) The query will use ST_Intersection with a subquery. SELECT bbox_nodes.id, bbox_nodes.tag, nodes_geom FROM (SELECT nodes.id, nodes.tag, ST_Intersection(nodes.the_geom, ...

7

New service from MySociety last week will get Administrative Boundaries for your chosen city. Example Paris http://global.mapit.mysociety.org/area/29746.html UK has better data source as using the OpenData from Ordnance Survey Example: Birmingham, UK note different url request http://mapit.mysociety.org/area/2514.html

6

You can make some test with completeWays, completeRelations or cascadingRelations options. On of them should do the trick .....(the first one I guess). If not, what about making your -bounding-box larger to keep all needed information, and crop again later after transforming data into shapefile or other format with your software tool. Edit : the ...

6

Google Maps Example: You can run this example from you local drive. You could simply add a form to enter the coords rather than the code. for changing the extents set the new google.maps.Rectangle({ bounds:new google.maps.LatLngBounds(new google.maps.LatLng(37.2, -122.3), new google.maps.LatLng(37.6, -121.9)), to the values you want. new ...

5

I just implemented this myself and posted my answer over on StackOverflow, but I figured I'd drop my version here for others to view: import numpy as np from scipy.spatial import ConvexHull def minimum_bounding_rectangle(points): """ Find the smallest bounding rectangle for a set of points. Returns a set of points representing the corners of ...

4

You request is a WMS request, but you have not completed the required configuration in the map file. In fact the map file that you have posted is only good for cgi usage through mapserver's own url format. You can either add the required WMS params to the map file and keep invoking mapserver as a WMS server (I would recommend this approach): http://...

4

The referenced article is thoughtful. However, I believe there is a "simple and elegant" solution: for geographic datasets, there are two kinds of bounding boxes. Those that do not straddle the +-180 meridian can be stored and searched as always. Those that do straddle the +-180 meridian can be stored in a semi-complementary form: namely, store the range ...

4

To get the zoom level, you'll need to know the pixel dimensions of your map. You'll also need to do your math in spherical mercator coordinates. Convert latitude, longitude to spherical mercator x, y. Get distance between your two points in spherical mercator. The equator is about 40m meters long projected and tiles are 256 pixels wide, so the pixel length ...

4

there is a topic here which similar to your question here... ST_Intersection — (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation does a transform to geometry to do the intersection and then transform back to WGS84. 1.you can also get some information here about Geometry Constructing ...

4

Terminology By definition, the scale is the amount by which (infinitesimal) distances are multiplied by the projection. Whenever a tiny displacement of d meters on the earth is associated with a displacement of d/s meters on the map, the scale is written as 1:s. It may depend on the direction of the displacement. The scale factor compares the scale at ...

4

Intersecting and clipping operations need at least 2 layers... I think you only have one layer and wish to save a subset in a new layer, am I right? If so, the process is: Select subset features Save selected features in a new layer To achieve (1), two possible ways: Select graphically the desired features manually on the map with one of the selection ...

3

The "bounding box" can have several interpretations. The two most natural are (a) the sides are meridians and the top and bottom are circles of constant latitude and (b) the sides are still meridians, but now the top and bottom are geodesics (which therefore do not necessarily have constant latitude). Fortunately, the solution method is the same in both ...

3

This is the C# code I use in Maperitive: public void ZoomToArea (Bounds2 mapArea, float paddingFactor) { double ry1 = Math.Log((Math.Sin(GeometryUtils.Deg2Rad(mapArea.MinY)) + 1) / Math.Cos(GeometryUtils.Deg2Rad(mapArea.MinY))); double ry2 = Math.Log((Math.Sin(GeometryUtils.Deg2Rad(mapArea.MaxY)) + 1) / Math....

3

To test whether a lat/lon is within or outside a bounding circle, you need to compute the distance from your reference lat/lon to the lat/lon point you wish to test. Since your distance is 10km or less, I would try using the Equirectangular approximation to get the distance rather than Haversine because of simplicity. To get the distance in km: x = (...

3

Assuming you want to make a query in a database, you probably want to make a fast (inaccurate) search, and afterwards calculating the distance for the resulting places exactly. Is that your scenario? The following function (in PHP, sorry) will roughly calculate the differences in latitude and longitude. This differences depend on the latitude of your search ...

3

Maybe try googling for specific indexing methods. For example, when I Google for C# r-tree this is the first result.

3

Sounds like you want the BBOX (Bounding Box) from your points - so ST_Extent would be favourable. BBOX2D http://www.bostongis.com/postgis_extent_expand_buffer_distance.snippet would provide the http://postgis.net/docs/ST_Extent.htm page but the server is having issues

3

I don't know much about gpsbabel, but here are a few examples with OGR: if you just need an approximation, you can use: ogrinfo -al -so infile.gpx Which will give you the binding box. Similarly, you can use ogr2ogr to pull out geometries which overlap a spatial extent with -spat: ogr2ogr -spat xmin ymin xmax ymax filtered.gpx infile.gpx If binding ...

3

FWIW, in Postgis is a function since 1.5, ST_Longestline that returns the longestline between two geometries. If you feed that function with the same geometry twice instead of two different, you will get the longest line in that geometry. http://postgis.net/docs/ST_LongestLine.html @Whuber. you write above that the longest line doesn't have to start and ...

3

I came across this thread while looking for a Python solution for a minimum-area bounding rectangle. Here's my implementation, for which the results were verified with Matlab. Test code is included for simple polygons, and I am using it to find the 2D minimum bounding box and axes directions for a 3D PointCloud.

3

If you're willing to work with the geometry's bounding box, here's a possible solution: First get the ymin, ymax and latitude span: osm=# select st_ymax(st_envelope(way)), st_ymin(st_envelope(way)), st_ymax(st_envelope(way)) - st_ymin(st_envelope(way)) as ylength from planet_osm_polygon where name = 'Sector 1'; st_ymax | st_ymin | ylength ---------...

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