New answers tagged python
1
vote
"builtins.ValueError: year 0 is out of range" error while iterating through features in layer with Fiona
You can skip it with the ignore_fields argument or only include fields you want with the include_fields argument, e.g:
import fiona
fc_path = "test.shp"
lyr=fiona.open(fc_path, 'r', ...
0
votes
Extract point cloud data from shapefile with Python
You can clip with pdals filters.crop:
The crop filter removes points that fall outside or inside a cropping
bounding box (2D or 3D), polygon, or point+distance.
I read the shapefile and convert the ...
1
vote
Converting UN locations `coordinates` to lat and lng
You can use Haskell like this
$ cabal repl -b geodetics
ghci> :m +Geodetics.Geodetic
ghci> showGeodeticSignedDecimal <$> readGroundPosition WGS84 "423000.00N,013100.00E"
Just &...
0
votes
New Features not snappable
Had a similar issue today in QGIS 3.40. In my case it was caused by the new feature triggering an update on the underlying databse, which QGIS did not get notified about. Interestingly the feature was ...
0
votes
Accepted
Unable to download MODIS emissivity through pystac
As Son of a Beach mentioned in his answer, MODIS data is probably not available anymore through planetary_computer.
Based on that answer to another issue (with some minor corrections), I managed to ...
1
vote
Unable to download MODIS emissivity through pystac
I did a bit of research and found this NASA news article which states:
These datasets will be available via their current URLs and workflows until June 26, 2025.
After that date, the legacy HTTPS ...
0
votes
Uploading style (SLD) to GeoServer using REST API not working - for empty workspaces
To temporarily resolve the issue, I created a function that first creates the SLD, then immediately updates it—using the same SLD content. Since this is for internal use, I will continue with this ...
0
votes
Natural Breaks (Jenks) classification using Python
A web search suggests mapclassify. Have you tired that?
import mapclassify
import numpy as np
data = np.array([1, 2, 3, 7, 8, 9, 15, 16, 17, 20])
n_classes = 3
classifier = ...
1
vote
AttributeError: 'DataFrame' object has no attribute 'to_file'. Did you mean: 'to_pickle'?
With @Bera's answare, i found the problem.
Adding some debbug in the layer_mapper() method, I found this:
def layer_mapper(gdb_path: str, layers: list[str], substation_cod_id_filter: str | None = None,...
3
votes
Accepted
AttributeError: 'DataFrame' object has no attribute 'to_file'. Did you mean: 'to_pickle'?
Yes, you can convert the dataframe to a geodataframe even though it doesnt have a geometry, then use .to_file:
import os
import geopandas as gpd
out_gpkg = r"C:\GIS\GIStest\abababa\out.gpkg"...
2
votes
Why does gdal.Warp create a black region on the sides of some rasters when it reprojects and cuts them?
I think it's something to do with the curve that should be introduced when the the cutline poly is internally reprojected to 3857 during the clip. If you reproject the poly manually, you will see that ...
3
votes
Accepted
Landsat Imagery comes up all white inside ROI
It's the scaling factor. You used a scaling factor of 0.0001, which is correct for Sentinel 2 but not for Landsat. For optical (RGB) bands in Landsat 9 images you have a different scaling factor and ...
1
vote
Extracting specific lat and long values in GeoTIFF file using Python
You can use rasterio's sample_gen():
import rasterio
from rasterio.sample import sample_gen
raster = r"C:\Users\bera\Desktop\gistest\abc\dem.tif"
coords = [[15.5673178 , 57.38489456],
...
0
votes
0
votes
Accepted
Getting rid off black/RGB pixels on edges caused by during reprojection with Python
Nodata does not really work with lossy compression methods. I believe you have two options:
Don't use "ADD_ALPHA=NO", use "ADD_ALPHA=YES"
Or continue without alpha but use a ...
1
vote
Dividing Geographical region into equal sized grid and retrieving indexing position
import geopandas as gpd
from shapely.geometry import box
import numpy as np
#Create a GeoSeries with the extent rectangle
ymin, xmin = 39.77750000, 116.17944444
ymax, xmax = 40.04722222, 116.58888889
...
4
votes
Accepted
Truncate layer in ArcGIS Online using arcgis.gis
Perhaps, the Esri community is a bit more comprehensive, where one can find more details when working with the ArcGIS API for Python.
In one of the threads i.e. "How to access layer using feature ...
Top 50 recent answers are included
Related Tags
python × 12252qgis × 2349
gdal × 1900
geopandas × 1208
pyqgis × 1107
arcpy × 1065
raster × 840
arcgis-desktop × 787
shapely × 697
rasterio × 621
shapefile × 616
coordinate-system × 611
ogr × 445
geotiff-tiff × 348
postgis × 334
qgis-plugins × 323
polygon × 311
numpy × 269
arcgis-10.0 × 250
geojson × 233
fiona × 219
arcmap × 213
arcgis-10.1 × 207
google-earth-engine × 204
geometry × 204