Tag Info

Hot answers tagged

16

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


16

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


9

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

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;


8

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


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


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


4

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


4

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


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


3

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


3

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


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

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


3

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


2

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.org/documentation/manual-1.5/ST_LongestLine.html @Whuber. you write above that the longest line doesn't ...


2

JTS provides a Minimum Bounding Circle (http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/algorithm/MinimumBoundingCircle.html) and a Minimum Diameter (http://tsusiatsoftware.net/jts/javadoc/index.html) - once you have those the rectangle should be easy to calculate.


2

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 postgis.refractions.net/docs/ST_Extent.htm page but the server is having issues


2

Well, I'm not sure I understood well your question since it appears to be too simple. But let's go. If your coordinates are y,x formatted, and you have : topLeft : 42,10 bottomRight : 31,21 then, to calculate bottomLeft, you get the y from bottomRight and get the x from topLeft and to calculate topRight, , you get the y from topLeft and get the x from ...


2

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


2

Your timeit includes the numpy import, which would add some overhead. So why don't you write the code for a subset of the bounding boxes and time that loop, then multiply it up to estimate the total running time? Solving it on a single computer is by its nature serial, and with a relatively simple operation, you might not get any significant optimization ...


2

You can get your all your table data and find the bounds from the response: var bounds = new google.maps.LatLngBounds(); for(i = 0; i < numRows; i++) { var point = new google.maps.LatLng( parseFloat(response.getDataTable().getValue(i, 0)), parseFloat(response.getDataTable().getValue(i, 1))); bounds.extend(point); ...


2

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


2

I think you might be missing the Filter/Spatial.js class, though it looks like it should be pulled in automatically by the BBOX Strategy without any work for you when you use the build tools. I would say that adding that should work -- and if it doesn't, I think that a simple set of OpenLayers code that demonstrated the problem with the build you're using ...


1

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


1

when you look at BBOX.js in lib from openlayers dir you can see sth. like this: /** * @requires OpenLayers/Strategy.js * @requires OpenLayers/Filter/Spatial.js */ when you add this two file to system, i think your problem will be solved. i hope it helps you...


1

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: http://stackoverflow.com/a/14675742/1755401 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. ...


1

I'm not sure what environment you're working in, but because UTM zones are referenced to a unique central meridian, the longitude of a point should be within +/- three degrees centered on the central meridian of your target UTM zone. Regarding a projectable/renderable bounding box of a UTM zone, ESRI datasets that come with ArcGIS should contain a UTM zone ...


1

Hi I am not sure how to use GIS for this. But since you said you need speed, you can do some math yourself. You have a point P in space and you have coordinates of that point. You can assume a sphere centered at earth's center. You get P(x1,y1) in space. Now, in the BB, which is not a box in fact since you got to see the curvature. So a surface which is ...


1

If your maps are always going to be in a projected coordinate system, that is locations are expressed in linear units, then you just need to know which units it's in and multiply by the relevant conversion factor. For instance, read in the epsg file that comes with proj.4, and parse it for the +units parameter or the +to_meters parameter. If, however, ...



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