Hot answers tagged

46 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 =[xmin:xmax, ymin:ymax] ...
jdmcbr's user avatar
  • 882
40 votes

Getting extent in OpenLayers 3?

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 ...
ThomasG77's user avatar
  • 29.8k
29 votes

Getting layer extent in 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
  • 16k
24 votes

Setting bounds and making map bounce back if moved away

[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 ...
elrobis's user avatar
  • 6,380
22 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,580
20 votes

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
  • 38.3k
17 votes

QGIS clip vector layer to current map extent

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
Joseph's user avatar
  • 74.6k
17 votes

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
  • 2,798
16 votes

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
15 votes

Getting canvas' extent coordinates using PyQGIS

You can get the current map canvas' extent by running this line of code in the QGIS Python Console: iface.mapCanvas().extent().toString() In case that you want the extent of the active layer (as ...
Germán Carrillo's user avatar
15 votes

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
  • 41.3k
14 votes

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.7k
13 votes

Visualizing bounding box as polygon

See >>> import shapely.geometry >>> bbox = (-125.056143, 31.8679566, -112.9017855, 42.4407224) >>> ...
Darren Weber's user avatar
13 votes

Finding minimum-area-rectangle for given points?

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 ...
JesseBuesking's user avatar
13 votes

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,728
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
  • 59.2k
11 votes

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,652
11 votes

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,390
11 votes

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
  • 28.4k
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 in 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,096
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
9 votes

How to create an Atlas based on point attributes?

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 ...
JonoPatterson's user avatar
9 votes

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
8 votes

How to find the extent of (many) EPSG CRSes?

You can download the EPSG data from after you register. No cost to register, and no delay between registration and download. There are two formats that might be ...
BradHards's user avatar
  • 12.7k
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

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
  • 19.2k
8 votes

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

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
  • 13.7k
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:,52,14,53 (add bbox as url hash to share map with box) Alternatively, I also found bboxfinder ...
sal's user avatar
  • 382

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