POST
|
Thanks StaticK. It is a shame ESRI haven't streamlined some of this via arcpy - especially considering how powerful it'd be in an arcpy toolbox.
... View more
01-09-2024
06:36 AM
|
0
|
0
|
227
|
POST
|
Thanks Dan, I actually started there but only seemed to have the option of reporting bugs about installation. Ill have another look.
... View more
11-09-2023
02:09 AM
|
0
|
0
|
231
|
POST
|
Hello, The recent update Pro 3.2 (and GDAL) has broken the ability for GDAL to open WCS urls. We rely on this for some plugins. Running below code in Pro <= 3.1 works perfectly (returns a dataset), but results in ERROR 4 for Pro 3.2. I tried below on the latets version of GDAL outside of Pro and it also works fine. Any advice? Thanks! from osgeo import gdal
url = 'https://ows.dea.ga.gov.au/wcs?service=WCS&VERSION=1.0.0&REQUEST=GetCoverage&COVERAGE=ga_ls5t_nbart_gm_cyear_3&MEASUREMENTS=blue,green,red,sdev&TIME=1991-01-01&BBOX=-1491464.3902944827,-3760705.2463235464,-1485657.8995810281,-3753979.4918812234&CRS=EPSG:3577&RESX=30&RESY=30&FORMAT=GeoTIFF'
ds = gdal.Open(url, gdal.GA_ReadOnly)
print(ds)
... View more
11-09-2023
01:46 AM
|
1
|
2
|
292
|
POST
|
Hello, I recently upgraded to Pro 3.2 and I'm now experiencing unexpected behaviour with the Register Raster tool in certain circumstances. I have a function hat registers numerous rasters in a loop to a reference. Every so often a raster identical to the reference is put through the tool. When this happens, the registered raster is sent kilometres away - but only when both rasters are identical. Is this expected behaviour? Thanks
... View more
11-08-2023
04:17 AM
|
1
|
0
|
183
|
POST
|
Further information: this appears to be an issue with pandas/xarray https://github.com/pydata/xarray/issues/8282
... View more
11-08-2023
12:25 AM
|
0
|
0
|
603
|
POST
|
Hello, The recent Pro 3.2 update has broken some of the basic core features of the Xarray Python library which we rely on quite heavily and for years have had no issues with in Pro. I have a netcdf file with x, y and time dims (see attached). I put it through the following code in a Pro notebook: import xarray as xr
# load netcdf
ds = xr.open_dataset(r"C:\R2016-02-12.nc")
# this results in error now
ds.resample(time='1YS').mean()
# this results in error now
ds.interpolate_na('time').mean() The resample function results in a type error: __init__() got an unexpected keyword argument 'base'. Looking on the net indicates this could be due to an incompatibility between Xarray and python versions. The interpolate_na fucntion returns an attribute error: 'DatetimeIndex' object has no attribute 'is_monotonic'. I have tried on several netcdfs with multiple dates and same issue. All data tested worked a week ago in Pro 3.1 (and earlier), so something has happened with Pro 3.2. Normally I'd find a work around but because these functions are fundamental to the Xarray library (and to our plugins!) I have submitted here. Any advice or knowledge on this would be appreciated. Lewis
... View more
11-08-2023
12:10 AM
|
1
|
2
|
668
|
POST
|
Hello all, I am trying to get some basic code that uses the multiprocessing module to work in a Pro 3.1 toolbox but it just won't play nice. The code: import time
import arcpy
import multiprocessing as mp
def work_log(work_data):
arcpy.AddMessage(" Process %s waiting %s seconds" % (work_data[0], work_data[1]))
time.sleep(int(work_data[1]))
arcpy.AddMessage(" Process %s Finished." % work_data[0])
def pool_handler(work):
p = mp.Pool(2)
p.map(work_log, work)
if __name__ == '__main__':
work = (["A", 5], ["B", 2], ["C", 1], ["D", 3])
pool_handler(work) If I run this in an .atnx or .pyt I get the same error: PicklingError: Can't pickle <function work_log at 0x00000134B287D430>: attribute lookup work_log on __main__ failed I also get 2 new instances of Pro open automatically if I run in a .pyt toolbox, I assume due to lack of __main__. Does anyone have any advice on how to get something like this running in a Pro toolbox (preferably .pyt)? I came across a similar question here https://community.esri.com/t5/python-questions/using-multiprocessing/m-p/1280108 but it has never been answered. Thanks!
... View more
10-18-2023
06:25 AM
|
0
|
3
|
456
|
POST
|
I am trying to do something almost identical to this and I'm getting a "cannot pickle my_body function" error. This is the same for an atbx and non-atbx toolbox script, although the latter also opens ~10 instances are arcgis pro (I assume due to the workers calling Pro.exe, not Python.exe). Does anyone have a working solution for using multiprocessing in a Python toolbox? I need to use it for processing numpy arrays, not geoprocessors.
... View more
08-19-2023
01:18 AM
|
0
|
0
|
405
|
POST
|
Hello, I have a python toolbox that has a tool in it that I want to run from the Pro Net side. Easy to do. However, I was wondering if it is possible to pass the geoprocessors messages and progressor values out of the geoprocessor into Net as the geoprocessor runs. Is this possible? Basically, I'm trying to create an improved dockpanel UI for the geoprocessor, but I need to do the processing on the python toolbox side. Thanks!
... View more
01-24-2023
10:57 PM
|
0
|
1
|
248
|
POST
|
Hello, I have a full Landsat scene that contains the usual bands (RGB NIR etc) as well as a seperate QA cloud mask band with the exact same dimensions and pixel size. I am trying to set all pixels in the full Landsat scene to NoData (-1) wherever a value of 0, 2, or 3 exist in the cloud mask. Are there any efficient approaches to this in the SDK? I came across the Mask Function (not the GP tool) in Pro, but from what I understand these are not available in the SDK. I also do not have access to Spatial Analyst to use Extract By Mask. I've currently implemented a a for loop that basically iterates the cloud mask and whenever the value is found, updates the same pixel in the full Landsat scene, but it seems suboptimal to me. I was looking at the GetNoDataMask and SetNoDataMask methods but as far as I'm aware my raw tiffs do not have these encoded. Cheers
... View more
08-29-2022
07:28 PM
|
0
|
0
|
199
|
POST
|
Hello all, I was wonder if it is possible to NuGet GDAL for use in a .NET Addin module? I got the recommended GDAL 3.5.0 and GDAL.Native 3.5.0 NuGet libraries via Visual Studio 2022 and everything came in fine. However, when running the required GdalConfiguration.ConfigureGdal() command, I get an exception: "The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception." I've looked around and there's not a heap of information on it. If I create a new C# project without ArcGIS SDK I can use GDAL without any issues, so I am assuming this is a ArcGIS Pro conflict? Any tips appreciated.
... View more
08-22-2022
05:40 AM
|
0
|
5
|
1383
|
POST
|
Thanks Wolf, I ended up using IProgress to increment my progress bar. Basically, I associate my ProgressValue (which is bound to UI) with IProgress, and then just use progress.Report(i) within my button RelayCommand logic to increment it. Seems to work perfectly. Do you think this is a valid approach?
... View more
08-22-2022
05:04 AM
|
0
|
0
|
309
|
POST
|
Hello all, I've been trying to implement a progress bar on a dock pane that increments as a function in a separate class downloads a list of GeoTiffs using HttpClient. I've successfully got this to work using the approach provided in the code sample Overlay3D. However, unlike this example, my list of tasks I want to increment occurs in a separate function outside of the dock pane, and I'm not sure how to pass the information from that function back to the dock pane. Any advice is welcome. I have provided a cut down code example below of my current setup, the comments should show where I am getting stuck: XAML progress bar, with two bindings (MaxProgressValue and Progress Value) back to dock pane view model. <!-- Progress bar-->
<ProgressBar Name="PrgProgressBar"
Grid.Column="0"
Margin="0,0,5,0"
Height = "10"
HorizontalAlignment="Stretch"
Minimum="1"
Maximum="{Binding Path=MaxProgressValue, Mode=OneWay}"
Value="{Binding Path=ProgressValue, Mode=OneWay}"
IsIndeterminate="False">
</ProgressBar> ViewModel related to progress bar, with a button to call a function to download geotiffs. // Getter, Setter for progress bar
private double _maxProgressValue = 100;
public double MaxProgressValue
{
get { return _maxProgressValue; }
set { SetProperty(ref _maxProgressValue, value, () => MaxProgressValue); }
}
// Update progress bar method (based on Overlay3D)
private int _iProgressValue = -1;
private int _iMaxProgressValue = -1;
private void ProgressUpdate(int iProgressValue, int iMaxProgressValue)
{
if (System.Windows.Application.Current.Dispatcher.CheckAccess())
{
if (_iMaxProgressValue != iMaxProgressValue)
{
MaxProgressValue = iMaxProgressValue;
}
if (_iProgressValue != iProgressValue)
{
ProgressValue = iProgressValue;
}
}
else
{
ProApp.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(() => {
if (_iMaxProgressValue != iMaxProgressValue)
{
MaxProgressValue = iMaxProgressValue;
}
if (_iProgressValue != iProgressValue)
{
ProgressValue = iProgressValue;
}
}));
}
}
// Button on dock panel to run download function
public ICommand CmdRun
{
get
{
return new RelayCommand(async () =>
{
// Excluded various things
// ...
// Initialise data structure STAC that contains urls and functions
Stac stac = new Stac(...)
// Reset progressor value and maximum value
ProgressUpdate(1, stac.Result.Features.Count);
// Start queued task and download geotifs
await QueuedTask.Run(() =>
{
// Begin download tifs loop
// How do I monitor progession?
// Pass a progressor variable via IProgress?
await stac.DownloadFeaturesAsync(assets, outputFolder);
});
}
} Stac class for DownloadFeatureAsync. public async Task DownloadFeaturesAsync(List<string> assetNames, string outputFolder)
{
// Some uninteresting work...
// ...
// Iterate dates in STAC query and download tif to folder
foreach (string date in dates)
{
// Open a HTTP client
var client = new HttpClient();
// Create a list of downloader tasks
int i = 0; // test
var tasks = new List<Task>();
foreach (var item in items)
{
string date = item.Key;
string url = item.Value[0];
string filename = item.Value[1];
tasks.Add(Task.Run(async () =>
{
// Do some things...
// Query URL and ensure success
var response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
// Download file to output folder
using (FileStream fs = new FileStream(filepath, FileMode.CreateNew))
{
await response.Content.CopyToAsync(fs);
}
// Increment progress bar... how...?!
// ...
}));
}
// Run all download tasks
await Task.WhenAll(tasks);
}
... View more
08-17-2022
07:50 AM
|
0
|
2
|
383
|
POST
|
Thanks Wolf and Jim, I ended up speeding this up using an approahc similar to Wolf's example, except I converted the 2D arrays into 1D arrays and using LINQ to quickly get a count of all unique values within the Raster: Raster raster = rasterDataset.CreateFullRaster();
// Get a pixel block for quicker reading and read from pixel top left pixel
PixelBlock block = raster.CreatePixelBlock(raster.GetWidth(), raster.GetHeight());
raster.Read(0, 0, block);
// Read 2-dimensional pixel values into 1-dimensional byte array
Array pixels2D = block.GetPixelData(0, false);
byte[] pixels1D = new byte[pixels2D.Length];
Buffer.BlockCopy(pixels2D, 0, pixels1D, 0, pixels2D.Length);
// Count percentage of valid pixels and keep if > minimum allowed
double totalPixels = pixels2D.Length;
double validPixels = pixels1D.Where(e => validClasses.Contains(e)).ToArray().Length;
... View more
08-17-2022
05:35 AM
|
0
|
0
|
900
|
Title | Kudos | Posted |
---|---|---|
1 | 11-09-2023 01:46 AM | |
1 | 11-08-2023 04:17 AM | |
1 | 11-08-2023 12:10 AM | |
7 | 07-16-2021 12:49 AM | |
14 | 05-10-2014 04:34 AM |
Online Status |
Offline
|
Date Last Visited |
01-09-2024
02:42 PM
|