Using the Vector Overlay->Extract/clip by extent tool in the processing toolbox will produce almost what you want:
But as you can see you get the bounding box not the actual boundary of the raster. I had hoped you could use the Vector geometry->Minimum bounding geometry but that only works on vector layers.
So if you must have the exact matching ...
you can do a query (select by expression in the attribute table) and then save the elements selected by the query (query based on attributes) or make a manual selection in the map windows and save/export the layer using selected features only ...
Create a grid (vector -> research tools -> create grid) covering the area of the city you need to be covered. Your gridsize seems to be about 100 by 100 m, use this for vertical and horizontal distances. Make sure you get polgyons, not any other type of grid.
Make sure your grid-polygons all have an ID.
Use vector -> data management tools -> join ...
You won't be able to use Clip to extract a continental US unless you already have another continental US feature. You can, however, Select and Export the features you need.
Choose the Select by Rectangle tool.
With the Select by Rectangle tool, draw a rectangle around the continental US.
After you complete the rectangle, your selected features will be ...
You just need to replace:
out_raster = os.path.join(out_folder,raster)
Or out_raster will be a tuple:
('C:\\folder', 'raster.tif'), instead of a path: 'C:\\folder\\raster.tif'
You cannot clip a vector layer with a raster layer, so do the following
Use Processing Toolbox > Layer Tools > Extract layer extent for the scanned map layer.
Now you can use Processing Toolbox > Vector overlay > Clip and choose the OS data shapefile as Input layer and the extent layer generated in Step 1 as the Overlay layer.
The -spat parameter in ogr2ogr https://gdal.org/programs/ogr2ogr.html#ogr2ogr affects all available layers. This selects data withing the given rectangle from all layers if you write only the name of the datasource into the command but not the layername. So just "...input.gpkg" instead of "...input.gpkg selected_layer".
ogr2ogr -f gpkg -spat 100000 6000000 ...
Reproject your vector and raster data into a projection that uses meter or feet units depending on your region and try the clip tool again. WGS84 can cause a problem because the pixel sizes of the raster data are in decimal degree. Using a projection of meter unit, for example UTM, can solve the problem.
I would recommend referencing The raster calculator No-data values which goes through
how to use the raster calculator to perform some operations on raster layers. We will also explain what are no–data values and how the calculator and other algorithms deal with them.
Another option may be in terms of NaN values occurring in your DEM, from what I'm aware,...
Let us assume we have a buildings layer (orange polygons: A, B, C) which is linked to another layer parcel (gray polygons: 101, 102, 103) by Parcel_Num attribute field.
We can use Geometry by Expression tool in Processing Toolbox | Vector geometry.
Click on the large Epsilon mark to open an expression dialog window:
Using Expression in QGIS Geometry by Expression tool -
Road layername is roads and it has road_no field to represent the road name (A, B, C)
State layername is states and it has state_no field (1, 2, 3)
Start Geometry by expression tool in the QGIS Processing toolbox - Vector geometry
Select your roads layer as input (1), and choose Line as ...
You can clip a raster by a vector easily, so first step is to convert your raster to vector.
GDAL > Raster Conversion > Polygonize.
You will have polygons with attribute called DN with values 0 and 1. Select all polygons with value 1 with expression like DN = 1
Use GDAL > Raster Extraction > Clip raster by mask layer. Select the polygonized layer as the ...
If you create a clipping layer with only the circular feature to use, your code can be simplified in this way (I use my own paths):
from osgeo import gdal, ogr
OutTile = gdal.Warp("/home/zeito/pyqgis_data/cut.tif",
I wonder if your dbase file is incomplete? The maximum size of a single dbase file is 2GB, yours is very close to the limit. It is odd, both your dbf files have the exact same byte count but the shp file is smaller. ESRI recommends using a file geodatabase instead of a shapefile.
This is not an answer, but it is too long for the comments. When making a call to a program outside python, I prefer to use subprocess. It allows you to see any error messages that result (e.g. thrown by ogr2ogr). Something like this:
callstr = ['ogr2ogr',
Assuming the layers are all in the current MXD, you could try something like this using Python and arcpy:
extentOfInterest = arcpy.Extent(xmin, ymin, xmax, ymax)
mxd = arcpy.mapping.MapDocument("CURRENT")
for layer in arcpy.mapping.ListLayers(mxd):
print "Layer overlaps and will be processed: " +...
It is correct that the two ways of clipping treat your quota consumption differently. You are free to continue using the Clip API with the understanding that it will be decommissioned and replaced with a new way of server-side clipping. To start doing things the "new way", please see the documentation here.
Example from the documentation:
"name": "just ...
You can also use the following:
for feature in features:
if "_clipped" in feature:
arcpy.Clip_analysis(in_features=feature, clip_features=clip_feature, out_feature_class=feature+'_clipped')
The continue statement in Python returns the control to the beginning of the for loop skipping the features which have _clipped ...
You can replace the last two lines with:
for feature in features:
if '_clipped' in feature:
Which will delete clipped fc outputs.
Then rerun the clip script. This is easier than checking for unclipped fc and clipped fc and clip if clipped fc is not found. Will be slower though since all fcs are clipped ...
This is easier with arcpy. If you dont want an arcpy solution I can delete my answer.
Script will list all feature datasets in database, and for each list all feature classes and then clip with specified clip feature. Outputs will be placed in the same feature dataset and with '_clipped' appended to name.
Make sure you have no feature datasets or feature ...
I can propose how to clip part of the source image by 512*512 (or whatever size) tiles
Create AOI by which you clip source image
Perform Raster Extraction Clipper (Qgis 3.2)
Using plugin Qtiles (available in Qgis 2.18) perform extracting tiles 512*512 into some directory
Then you have a lot of tile divided into several subdirectories respective to zoom ...
Mmm, really it depends on what you need the final outcome to be. Assuming you would want the outcome to be compatible in later analyses with the file you are clipping it to, I would re-project it first, then clip it to the file! If you would do it the other way around, the end result would probably not be perfectly clipped. That being said, observe caution ...
Heavy raster processing tasks are perfect candidates for multiprocessing.
import time, os
t0 = time.time()
from multiprocessing import Pool
You're on the right track by polygonizing the raster. Currently you're trying to polygonize the elevation raster, and the tool is trying to create a separate polygon for every elevation value (ie a polygon for 3500', another polygon for 3501', etc.) You could select and merge all the polygons with values > 3500, but there's a much faster method. First create ...