Skip to main content
48 votes

Filter by bounding box in GeoPandas

You can use the cx method on a geodataframe to select rows within a bounding box. For your example frames: xmin, ymin, xmax, ymax = df_sussex.total_bounds sac_sussex = df_sac.cx[xmin:xmax, ymin:ymax] ...
jdmcbr's user avatar
  • 914
30 votes
Accepted

Getting layer extent using PyQGIS

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 ...
mgri's user avatar
  • 16.3k
23 votes

Select all points within a bounding box

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 ...
kttii's user avatar
  • 3,630
20 votes
Accepted

Showing the bounding box for every coordinate system in QGIS

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 ...
JGH's user avatar
  • 42.3k
19 votes
Accepted

Getting the bounding box for each feature in the source layer in QGIS

In the Processing Toolbox (Processing Tab > Toolbox or Ctrl+Alt+T) you will find a tool called Bounding boxes. This will achieve what you want. If your layer contains some multipart features you ...
Cushen's user avatar
  • 3,167
16 votes

Visualizing bounding box as polygon

See https://shapely.readthedocs.io/en/latest/manual.html#shapely.geometry.box >>> import shapely.geometry >>> bbox = (-125.056143, 31.8679566, -112.9017855, 42.4407224) >>> ...
Darren Weber's user avatar
16 votes
Accepted

Using resample vs. aggregate & extend in R to have rasters of matching resolution and extent

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 <-...
aldo_tapia's user avatar
  • 13.7k
15 votes
Accepted

Getting correct WKT result to 4 decimal places using PostGIS

The simplest way to round geometry coordinates is to use ST_SnapToGrid: SELECT ST_AsText(ST_SnapToGrid('POINT(-0.685239554498251 51.4940418030595)', 0.0001)); st_astext ----------------------- ...
Mike T's user avatar
  • 42.2k
15 votes
Accepted

Difference between bounding box, envelope, extent, bounds?

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 ...
Fezter's user avatar
  • 21.9k
14 votes
Accepted

Getting bounding box from Point type GeoDataFrame to getting data from Osmnx

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({'...
joris's user avatar
  • 3,923
13 votes
Accepted

Spherical Mercator - World bounds

The bounds for EPSG 3857 are: xmin: -PI * 6378137, ymin: -PI * 6378137, xmax: PI * 6378137, ymax: PI * 6378137 which result in the following bounds: xmin: -20037508.3427892, ymin: -20037508....
Ralph Tee's user avatar
  • 1,732
12 votes

Sum rasters with different extent in R

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 ...
Spacedman's user avatar
  • 65.1k
11 votes
Accepted

Creating "oblique bounding box" with maximum width/height ratio?

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, ...
MickyT's user avatar
  • 3,430
11 votes
Accepted

Filter by bounding box in GeoPandas

Issue is because you are using 'total_bounds' method. It only produces a tuple with max and min points of bounding box. Method to be used is 'envelope'; previous to build its respective 'GeoDataFrame'....
xunilk's user avatar
  • 30k
10 votes

Increasing extent of Raster?

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 ...
Wilmar van Ommeren's user avatar
10 votes

Getting layer extent using PyQGIS

you were on the right track you just need to go a step further. See the QGIS documentation for QgsRectangle Basically, you do: get the current Layer layer = iface.activeLayer() get the extent ...
LaughU's user avatar
  • 4,196
10 votes

Creating polygon around set of points without blank polygon spaces in between in PostGIS

I was able to get the desired result using Minimum Spanning Tree as @Bera had suggested. I looked into it and followed the steps mentioned in the already answered question in the link Finding the ...
George V's user avatar
  • 339
10 votes
Accepted

Copy extent from one map to another in QGIS Layout

Synchronising the extents Perhaps the simplest way to synchronise the extents, that I am aware of, is making Maps 2 and 3 overviews of Map 1 (without a visible extent indicator). Ensure that the ...
Matt's user avatar
  • 17.6k
9 votes
Accepted

How to replicate gdalwarp -cutline in Python to cut out tif image based on the extents.kml file

Using the GDAL Python bindings (GDAL >= 2.1), it should be: from osgeo import gdal input_raster = "path/to/rgb.tif" output_raster = "path/to/rgb_output_cut.tif" input_kml = "path/to/extent.kml" ds =...
Antonio Falciano's user avatar
9 votes
Accepted

Zooming to each vector layer extent, one at a time, using PyQGIS

You can solve your issue using QTimer which controls when to execute functions and it's asynchronous, i.e., it allows other functions to continue to run (think of a map.refresh()) while waiting some ...
Kadir Şahbaz's user avatar
8 votes

Convert polygon bounding box to geodataframe?

A full solution including imports: from shapely.geometry import box from geopandas import GeoDataFrame import pandas as pd INIT_PATH = './data.csv' df = pd.read_csv(INIT_PATH, sep='\t') geometry = [...
alemol's user avatar
  • 231
8 votes
Accepted

Shapefiles not aligning in QGIS?

I downloaded both files and they worked fine for me by simply dragging and dropping the .shp components onto the map canvas with the project CRS set to EPSG:4326. QGIS loaded the freeways layer in ...
Ben W's user avatar
  • 21.9k
7 votes

Is there a website that will let me see add markers and bounding boxes on top of a street map?

This will let you enter and display a bounding box on an OSM background: https://linestrings.com/bbox/#12,52,14,53 (add bbox as url hash to share map with box) Alternatively, I also found bboxfinder ...
sal's user avatar
  • 391
7 votes
Accepted

Clip raster with another raster (by extent) in Python

Found the solution #IN ORDER TO CLIP BY EXTENT EVERY IMAGE gt1=IMG1.GetGeoTransform() gt2=IMG2.GetGeoTransform() if gt1[0] < gt2[0]: #CONDITIONAL TO SELECT THE CORRECT ORIGIN ...
Italo Moletto Lobos's user avatar
7 votes
Accepted

QGIS Atlas generation for multiple map extents?

You assume correctly, that you need to have one feature for each map in thecovrage file. based on your image I would advise you to create a polygon layer, with 5 polygons, which represents the ...
LaughU's user avatar
  • 4,196
7 votes

gdal_translate -a_ullr flag

After testing, the -a_ullr flag assigns the outermost coordinates of your raster. That is, the corners of grid cells located in the corners of the grid. The command: gdal_translate -of GTiff -a_srs ...
G. Deemer's user avatar
  • 111
7 votes

Getting the bounding box for each feature in the source layer in QGIS

If you want to have a separate feature class for each bounding box, you need to use the iterate tool (click on the green arrow) to get a bounding box for each polygon. Without using the iterator, you ...
ahmadhanb's user avatar
  • 41.1k
7 votes
Accepted

Setting the study area boundaries in QGIS for nearest neighbor analysis?

Using Nearest neighbor analysis, the study area is automatically limited by the extent of the layer you use as input. Thus the x_min/x_max and y_min/y_max value define the limit: northernmost point ...
Babel's user avatar
  • 73.2k
7 votes

Showing the bounding box for every coordinate system in QGIS

You can generate an entire QGIS project showing all SRS code from QGIS internal srs.db using PyQGIS. It adds all layers from srs.db. I also directly style the layer to get transparent bbox. I've taken ...
ThomasG77's user avatar
  • 31k
7 votes
Accepted

Creating polygon covering the whole layer extent using QGIS expressions

You can define a custom function to get crs extent. from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom') def crs_extent(layer_name, feature, parent): layers = ...
Kadir Şahbaz's user avatar

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