Hot answers tagged

5

The +init= syntax is deprecated. So all you need is the ESRI:102001 part. See: https://pyproj4.github.io/pyproj/stable/gotchas.html#init-auth-auth-code-should-be-replaced-with-auth-auth-code inputGDF.crs = 'esri:102001'


4

from shapely.geometry import Polygon, Point import geopandas polys1 = geopandas.GeoSeries([Polygon([(0,0), (2,0), (2,2), (0,2)])]) polys2 = geopandas.GeoSeries([Polygon([(1,1), (3,1), (3,3), (1,3)])]) df1 = geopandas.GeoDataFrame({'geometry': polys1, 'df1':[1], 'content':[10]}) df2 = geopandas.GeoDataFrame({'geometry': polys2, 'df2':[1], 'content':[20]}) #...


3

Assuming your three rasters have the same dimensions, you can use numpy's boolean indexing to accomplish this. First, you need to create three masks, each one corresponding to one of your conditions: con1 = (dcl_array == 1) # raster a is 1 con2 = (dcl_array == 0) # raster a is 0 con3 = (tcd_array == 0) # raster c is 0 Then, you just have to index the ...


3

In Python, this would be: import gdal import osr driver = gdal.GetDriverByName('GTiff') spatref = osr.SpatialReference() spatref.ImportFromEPSG(27700) wkt = spatref.ExportToWkt() outfn = '/path/to/out.tif' nbands = 1 nodata = 255 xres = 5 yres = -5 xmin = 0 xmax = 680000 ymin = 0 ymax = 1240000 dtype = gdal.GDT_Int16 xsize = abs(int((xmax - xmin) / ...


2

There are a couple of issues with the code: You're invoking export_image() with the wrong argument order. Like you pointed out, your image doesn't contain a VH band. You have to remove all references to it. Instead of doing that, I typically filter out images that doesn't contain both VV and VH. There is problems with your geometry. I didn't try to figure ...


2

You have another function for doing this: from processing import execAlgorithmDialog params = {} # A dictionary to load some default value in the dialog execAlgorithmDialog('qgis:extractbyattribute', params)


1

With the builtin GDAL utilities you can first make the VRT with gdalbuildvrt: gdalbuildvrt mosaic_file.vrt *.tif And then convert to Tiff and reproject with gdalwarp: gdalwarp -t_srs EPSG:32734 -of GTiff mosaic_file.vrt output.tif


1

Pillow isn't a geospatial library, I recommend looking at rasterio resampling For example: import rasterio from rasterio.enums import Resampling # Register GDAL format drivers and configuration options with a # context manager. with rasterio.Env(): with rasterio.open('/path/to/input.tif') as dataset: data = dataset.read(1, out_shape=(1200, ...


1

I would recommend a combination of geopandas and geocube. Here is some untested set of code that should get you pretty close to what you want to do. Step 1: Combine the shapefiles import pandas import geopandas gpd1 = geopandas.read_file("Shapefiles/shp1.shp") gpd2 = geopandas.read_file("Shapefiles/shp2.shp") gpd3 = geopandas.read_file("Shapefiles/shp3....


1

import shapefile as shp sfinput = shp.Reader(r"C:\...\fire_archive_M6_98806.shp") with shp.Writer(r"C:\...\Output") as w: w.fields = sfinput.fields[1:] # skip first deletion field for feature in sfinput.iterShapeRecords(): # iteration on both record and shape for a feature w.record(*feature.record) # * for unpacking tuple w....


1

You can solve it putting lines above mentioned in add_action method instead run method. To exemplify this, in my test plugin, I added a QTabWidget object and, inside first and second tabs, a QLabel object; as it can be observed in following image (only for first Tab). Afterward, I modified plugin code as follows for changing default text in Qt5 Designer ('...


1

Your query has a syntax error, namely an extra semicolon in the following line, which needs to be removed. relation[landuse=forest](area.searchArea);; Before trying any queries in Python, better test them in overpass turbo first, until they work correctly.


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