# Tag Info

45

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

40

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

37

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

33

Just do the following map.getView().calculateExtent(map.getSize()) // Nowadays, map.getSize() is optional most of the time (except if you don't share view between different maps), so above is equivalent to the following map.getView().calculateExtent() considering that map is the variable referencing an instance of ol.Map like at this official example. To ...

26

The following little Python function will output the bounding box coordinates of the currently active feature: def printBB(): feature = iface.activeLayer().selectedFeatures() print feature.geometry().boundingBox().toString() To define the function, open the Python console from the Plugins menu, copy and paste the three lines into the console, ...

19

Right-click the feature class in ArcCatalog and go to the Properties. In the Feature Extent tab, click on Recalculate. And voilà! I'm using ArcGIS 10.2.1

19

The layer extents are available in the Layer Properties | Metadata section.

18

Dont use env.extent you need to get raster extent. import arcpy elevRaster = arcpy.sa.Raster('C:/data/elevation') myExtent = elevRaster.extent print myExtent i hope it helps you...

18

This can simply be done by defining extent in the View object. eg var view = new ol.View({ ... extent: [minx,miny,maxx,maxy] ... }); var map = new ol.Map({ ... view: view, ... });

17

QGIS can do it via Polygon from Layer Extent Vector - Research tools - Polygon From Layer Extent Will produce a new shapefile with attributes like XMIN XMAX YMIN YMAX AREA WIDTH HEIGHT

16

They probably set it to a fixed extent. If you right click the data frame, go to properties, and under the "Data Frame" tab you can set the extent to "Automatic" which should allow you to move things around.

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

15

This will return you the extent of the canvas. extent = iface.mapCanvas().extent() Reference: http://qgis.org/api/classQgsMapCanvas.html#a878f0c387c9475d59c6aac425db01020

15

In the Processing Toolbox, you can use the Clip vectors by extent tool from GDAL/OGR: Processing Toolbox > GDAL/OGR > [OGR] Geoprocessing > Clip vectors by extent

14

You have three problems with your statement though the error message is hinting only at part of it... "WHERE must be type boolean" means that the information you gave the WHERE is not evaluating to a boolean result. ST_MakeEnvelope asks for its parameters in this order: xmin, ymin, xmax, ymax, srid. You incorrectly passed in ymax, ymin, xmax, xmin, srid. ...

12

The answer is almost completely contained in a post I recently wrote. The extent is returned as a QgsRectangle() object with the following code: layer = iface.activeLayer() # load the layer as you want ext = layer.extent() For getting the coordinates of the vertices for the current layer, you may run this code: xmin = ext.xMinimum() xmax = ext.xMaximum() ...

11

I've created a small function for this very purpose and it has been used by others with good reviews! gClip <- function(shp, bb){ if(class(bb) == "matrix") b_poly <- as(extent(as.vector(t(bb))), "SpatialPolygons") else b_poly <- as(extent(bb), "SpatialPolygons") gIntersection(shp, b_poly, byid = TRUE) } This should solve your problem. ...

11

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

11

In ArcMap, normally you have the Data View, and you have a PageLayout View. Additionally, you'll have atleast one DataFrame, out of which only one can be active. This is reflected in the various ArcObjects Interfaces. The IMxDocument.FocusMap refers to the DataFrame which is in Focus. The IMxDocument.PageLayout refers to the PageLayout The IMxDocument....

11

[Final Answer] I bet you can easily resolve this by setting the map's maxBounds equal to its initial bounds immediately upon loading. :) Just add this to your initializing code once your map variable is ready. map.setMaxBounds(map.getBounds()); [Original Response] When you instantiate your Leaflet map, you just need to pass in a maxBounds option among ...

11

I think you'll find there is a bit of overlap with these definitions. They're all very similar, in my opinion. However, ESRI has a glossary of GIS terms, so I just looked them up. The definitions are similar or identical to the wiki GIS glossary as well. Bounding Box (Bounding Rectangle): [map display] The rectangle, aligned with the coordinate axes and ...

10

Okay, let's rock these features out of the DragBox! There are three options I have found to extract those features from the extent of the DragBox. Considerations and assumptions: I couldn't extract the layer types (raster or vector) from the map.getLayers() object, so let's assume that we stored the feature layers in individual global variables. The ...

9

how about... provider = vector.dataProvider() feat = QgsFeature() allAttrs = provider.attributeIndexes() provider.select(allAttrs) while provider.nextFeature(feat): geom = feat.geometry() rect = geom.boundingBox() #get bounding box as QgsRectangle

9

The Ogr function GetEnvelope() returns "a tuple (minX, maxX, minY, maxY)" (from here), but what you want (from what I can understand) is a Polygon describing the envelope/bbox? This is actually rather simple, as the tuple (minX, maxX, minY, maxY) is all you need to create a Polygon. Just create a Polygon based these, like so: from osgeo import ogr def ...

9

I've finally solved this for my purposes so here's the solution I came up with if it helps anyone: Write a python script (mine at end of this) which essentially does this: identify the unique categories in the point layer field of interest for each category, select all matching points and establish the extent of this set for each extent generate a new ...

9

For future readers As user30184 mentioned in the comments, gdalwarp is also working and easier than the accepted answer. Run the following command with your specific arguments to change (increase is also working) your raster extent: gdalwarp.exe -te xmin ymin xmax ymax old_extent.tif new_extent.tif Ensure that your outputfile (in this case new_extent.tif) ...

9

Check resample function of raster package. When resample is used with 'bilinear method, the output is the same one than aggregate: if (!skipaggregate) { rres <- res(y) / res(x) resdif <- max(rres) if (resdif > 2) { ag <- pmax(1, floor(rres-1)) if (max(ag) > 1) { if (method == 'bilinear') { ...

9

This is probably overkill on the processing front and there is likely to be a better mathematical solution, but as an example of a way that it could be done rather simply as a query SELECT id, rotated_by, oblique_bound FROM ( SELECT m.id, r rotated_by, ST_Rotate(ST_Envelope(ST_Rotate(m.geom, r)),-r) oblique_bound, ...

8

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

8

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

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