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 = df_sac.cx[xmin:xmax, ymin:ymax]
...
40
votes
Accepted
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 ...
29
votes
Accepted
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 ...
24
votes
Accepted
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 ...
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 ...
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 ...
17
votes
Accepted
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
17
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 ...
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 <-...
15
votes
Accepted
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 ...
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
-----------------------
...
14
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 ...
13
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)
>>> ...
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 ...
13
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({'...
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 ...
11
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....
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, ...
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'....
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 ...
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 ...
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 ...
9
votes
Accepted
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 ...
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 =...
8
votes
Accepted
How to find the extent of (many) EPSG CRSes?
You can download the EPSG data from http://www.epsg.org/DownloadDataset after you register. No cost to register, and no delay between registration and download.
There are two formats that might be ...
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 = [...
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 ...
8
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 ...
8
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
extents × 810qgis × 121
raster × 98
coordinate-system × 90
arcgis-desktop × 89
python × 67
openlayers × 62
r × 59
postgis × 56
arcpy × 50
pyqgis × 40
geoserver × 34
arcmap × 32
polygon × 30
gdal × 29
coordinates × 27
clip × 27
arcgis-maps-sdk-javascript × 27
wms × 24
arcgis-pro × 22
shapefile × 20
leaflet × 19
layers × 19
wfs × 18
geometry × 17