Hot answers tagged

37

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


28

The following little Python function will output the bounding box coordinates of the currently active feature: def printBB(): feature = iface.activeLayer().selectedFeatures()[0] 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, ...


21

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


20

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.


19

Yes, QGIS holds this information in an SQLite table. Go the menu layer / data source manager and select Browser then go to where QGIS is installed (like C:\Program Files\QGIS 3.16\) and dig down to apps\qgis-ltr\resources\ (or \qgis-dev\) and at last open the srs.db and add tbl_bounds To view the bounds as geometries, we will need a virtual layer. Go the ...


18

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


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

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


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.


16

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


16

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


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

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') { ...


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

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

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

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


11

You can use the total_bounds property for this. Small example: In [83]: from shapely.geometry import Point In [84]: import geopandas In [86]: import random In [87]: df = geopandas.GeoDataFrame({'geometry': [Point(random.random(), random.random()) for _ in range(10)]}) In [93]: df Out[93]: geometry 0 POINT (0....


10

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


10

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


10

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


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


10

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


10

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


9

I use a code similar to this. Try using the following code (its modified from what I use and this is untested). # Import arcpy modules import arcpy from arcpy import env def extents(fc): extent = arcpy.Describe(fc).extent west = extent.XMin south = extent.YMin east = extent.XMax north = extent.YMax width = extent.width height = ...


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

Sample data: r1 = raster(xmn=0,xmx=11,ymn=0,ymx=11,res=1) r1[]=1:ncell(r1) r2 = raster(xmn=5,xmx=8,ymn=6,ymx=9,res=1) r2[]=1:ncell(r2)+5 Now two functions, first to get the max extent of a list of rasters: extend_all = function(rasters){ extent(Reduce(extend,rasters)) } Then one to sum all rasters padded to a specified extent: sum_all = function(...


8

If you want only the extent of one image and not the full directory you can go to Vector->Research Tool->Polygon from layer extent here select the image you want the extent and save the output.


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