Tag Info

Hot answers tagged

23

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


21

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


13

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


10

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


9

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;


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


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


5

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


5

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


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

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

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

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


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

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

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

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


3

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


3

calculate the width and height of the box by subtracting one corner from the other then add half the width to the left edge and half the height to the bottom edge.


3

for a small bbox, in a long/lat coordinate system, you can assume the earth is flat at that area and you can use the average of x and y: >>> coords = (-38.6102467739459, -38.017601026186576, 33.01563382506067, 33.624945228091406) >>> centerx,centery = ( numpy.average(coords[:2]),numpy.average(coords[2:])) >>> ...


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

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

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

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


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

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



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