[gdal-dev] C# updates for GDAL (swig 3.0.8 & dotnet core 2.0)

2017-08-31 Thread Eric Wenger ARA/SED
All,

I have the [unfortunate] responsibility of delivering a piece of research code 
written in C# on Windows to a customer to be dockerized and run on CentOS 7.   
As a result, I have made a couple of commits to my gdal repo on Github that I 
would eventually like to incorporate into the mainline.  I'm happy to 
contribute these at some point, but I'd like to provide them to the community 
in the meantime in case anyone else can take a look or use them in their 
current work.

--Eric

1. Fix C# build issues with SWIG 3.0.8 (ewenger/gdal, branch csharp-swig3x, 
commit d7e3963).  This commit fixes a number of issues that have caused users 
to have difficulty building code generated with later versions of SWIG.   With 
this change, all build issues with SWIG 3.0.8 and Mono/VS .NET 4.x are resolved.

https://github.com/ewenger/gdal/commit/d7e3963f27a2b0a54078763e3cad61aab0f47885

2. Support building gdal using the .NET Core 2.0 framework/SDK.  (ewenger/gdal, 
branch dotnet-core-2.0, commit cfd8ce2).  This commit adds solution and project 
files that support building the csharp binding dlls using the .NET Core 2.0 
SDK.  I could use some advice here, since the new .NET Core 2.0 SDK is, as 
usual, unfriendly to external build tools.  From what I have learned so far, 
there is no way to call the new C# compiler directly and integrate the build 
into GDAL's makefile structure.  I'd like to find a way around committing 
solutions and projects, so please let me know if you have ideas.

https://github.com/ewenger/gdal/commit/cfd8ce2824c259c7c663f17ab8fdfd7365d4a408


--
Eric J Wenger, Senior Scientist
Southeast Division | Remote Sensing and Decision Analytics
Applied Research Associates, Inc.
8537 Six Forks Rd. Ste. 600 - Raleigh, NC 27615
T: 919-582-3449 F: 919-582-3301 M: 919-816-2864
www.ara.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Raster statistics

2017-08-09 Thread Eric Wenger ARA/SED
Paul,

You could call gdal_calc.py and pass it the numpy formulas on the command 
line…Otherwise it might be best to bring the raster in to OpenCV.

--Eric

From: gdal-dev [mailto:gdal-dev-boun...@lists.osgeo.org] On Behalf Of Paul Meems
Sent: Thursday, August 03, 2017 2:51 PM
To: Chris Waigl
Cc: gdal-dev@lists.osgeo.org
Subject: Re: [gdal-dev] Raster statistics

Thanks Chris for your reply.

I forgot to mention I'm not using GDAL with Python.
I use it with C++ and/or C#.




Paul

[http://www.bontepaarden.nl/bontepaarden/images/newButton.png]Paul Meems
Release manager, configuration manager
and forum moderator of MapWindow GIS.
www.mapwindow.org

Owner of MapWindow.nl - Support for
Dutch speaking users.
www.mapwindow.nl



The MapWindow GIS project has moved to GitHub!

Download the latest MapWinGIS mapping 
engine.

Download the latest MapWindow 5 open source desktop 
application.


2017-08-03 20:05 GMT+02:00 Chris Waigl 
>:
I would not use gdal for this particular task. I presume you have the band data 
in a 2D numpy array. Then I’d get the 80th percentile for example with 
np.percentile() and use a boolean expression to generate a mask for the array 
(droneraster > perc80value ).

Chris

--
Christine (Chris) Waigl - cwa...@alaska.edu -  
+1-907-474-5483 - Skype: cwaigl_work
Geophysical Institute, UAF, 903 Koyukuk Drive, Fairbanks, AK 99775-7320, USA






On Aug 3, 2017, at 5:43 AM, Paul Meems 
> wrote:

I have a drone raster file which I want to use for some calculation.
Before the calculation, I need to loose some extreme values.
I want to do something like a percentile calculation where you get all values, 
order them and loose the top 10%.
For this, I need to get all values first which can be slow when using a large 
file.

I looked at the statistics (band.GetStatistics) but that doesn't work well.
I thought I could use 2 times the standard deviation added to the mean to get 
roughly 97%.
But with these statistics:
STATISTICS_MAXIMUM=33.186080932617
STATISTICS_MEAN=24.840205979603
STATISTICS_MINIMUM=1.5951598882675
STATISTICS_STDDEV=4.7285348016053
Mean + 2*std is larger than the max.

So I moved to the histogram. It is also very fast, but I'm not sure how to use 
it.
I have this:
  256 buckets from 1.53322 to 33.248:
  410 77 66 66 65 58 56 45 42 87 57 72 61 65 68 70 73 82 93 ...
Does this mean, bucket 1 = 410 that I have 410 pixels of value 1.53322 and the 
second bucket means I have 77 pixels between 1.53322 and 1.657? 1.657 = 1.53322 
+ ((33.248 - 1.53322)/256)

Is this a good approach? Or can/should I use a different one.

Thanks,

Paul
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Need solution for C# setup, with error at OSGeo.OGR registration

2017-08-08 Thread Eric Wenger ARA/SED
Chui,

An example here is that you need to have proj.dll in the path so that gdal.dll 
will load from the PInvoke.  You can use dependency walker to find other 
dependencies.

From: gdal-dev [mailto:gdal-dev-boun...@lists.osgeo.org] On Behalf Of Tamas 
Szekeres
Sent: Tuesday, August 01, 2017 12:15 PM
To: C. Zeng
Cc: gdal-dev@lists.osgeo.org
Subject: Re: [gdal-dev] Need solution for C# setup, with error at OSGeo.OGR 
registration

Hi,

You probably have multiple dll dependencies availabe in the path. Try copying 
all the dependencies from the same package to the location where your excutable 
is running.

Best regards,

Tamas

Az iPhone-omról küldve

2017. aug. 1. dátummal, 17:08 időpontban C. Zeng 
> írta:
​Hello all,

I am trying to setup the GDAL in C#.NET 2015, with an error at the registration 
of the Ogr. A previous 
post
 stated the exact same problem but without a solution, I tried to reply in that 
post but failed,thus send this email instead.

That previous post described my problem very well:
"I am using ogr_csharp.dll in my c# program. See the following code snippet:
using OSGeo.OGR;
namespace Test
{
public class Test
{
public Test()
{
...
  Ogr.RegisterAll();
}
}
}
Then the following exception message was thrown out when the program is 
executed:
{"The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception."}
System.Exception {System.TypeInitializationException}
Does anyone know how to resolve this issue? "

Some more details for my case. My steps are:
- downloaded the stable or daily stable release (same error later) from 
here.
- added the "...\bin" and "...\bin\gdal\csharp" to Environment Variable, setup 
a sample project,
- add the 4 "###sharp.dll" from csharp folder to project reference.
- import namespace:  using OSGeo.OGR; using OSGeo.OSR;  and add a simple line 
"Ogr.RegisterAll(); "

Then I can successfully build the project, but with the following error msg. I 
tried all possible solutions by Google plus this forum such as 
this
 and 
this.
test all the x64/x86 , debug/release, switches, no luck.

Any comment is appreciated, thank you!

Chui



--error message --

Unhandled Exception: System.TypeInitializationException: The type initializer fo
r 'OSGeo.OGR.OgrPINVOKE' threw an exception. ---> System.TypeInitializationExcep
tion: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> Sy
stem.BadImageFormatException: An attempt was made to load a program with an inco
rrect format. (Exception from HRESULT: 0x8007000B)
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Og
r(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, E
xceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate
, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDeleg
ate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, Exce
ptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, Exception
Delegate systemExceptionDelegate)
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..cctor()
   --- End of inner exception stack trace ---
   at OSGeo.OGR.OgrPINVOKE.SWIGExceptionHelper..ctor()
   at OSGeo.OGR.OgrPINVOKE..cctor()
   --- End of inner exception stack trace ---
   at OSGeo.OGR.OgrPINVOKE.RegisterAll()
   at OSGeo.OGR.Ogr.RegisterAll()
   at TestProj.Main(String[] args) in 
\user\Downloads\Workspace\TestProj\project.cs:line 47

and also the following log info:
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 
'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
 Cannot find or open the PDB file.
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'.
 Cannot find or open the PDB file.
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 
'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'.
 Cannot find or open the PDB file.
'TestProj.vshost.exe' (CLR v4.0.30319: TestProj.vshost.exe): Loaded 
'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'.
 Cannot find or open the PDB file.

Re: [gdal-dev] csharp/gdal/fwtools. Problem with migrating from window to ubuntu/mono

2017-08-08 Thread Eric Wenger ARA/SED
AndrewB,

Are you still working on this?   I just ported an app from Windows to C# using 
.net core 2.0 preview 2 and GDAL is working well in that environment.  

--Eric

-Original Message-
From: gdal-dev [mailto:gdal-dev-boun...@lists.osgeo.org] On Behalf Of AndrewB
Sent: Friday, June 16, 2017 5:16 AM
To: gdal-dev@lists.osgeo.org
Subject: [gdal-dev] csharp/gdal/fwtools. Problem with migrating from window to 
ubuntu/mono

I'm novice in csharp but i need to migrate csharp project from windows to 
linux(ubuntu)/mono and have problem with this.
I'm using FWTools in C# project under Windows(code below):
including in project 2 dlls and FWTools/Bin in $PATH:
ogr_csharp.dll
osr_csharp.dll

CODE:
using OSGeo.OGR;
using OSGeo.OSR;

private void GenerateMif( ...params... ) {
 Ogr.RegisterAll();
 using (var driver = Ogr.GetDriverByName("MapInfo File") )
using (var dataSource = driver.CreateDataSource(mifOutputPath,
null) )
{   
SpatialReference spatial = GetSpatialByProjection(projection);
var layer = dataSource.CreateLayer("layer1", spatial, 
wkbGeometryType.wkbUnknown, null);
CreateLayerFields(result, layer, fieldDefinitionParameters);


and its works.
 

Now i want migrate this functionality to mono/Ubuntu.  
I'm building project in Xamarin Studio from Windows under Mono/.NET platform 

Ogr.RegisterAll();  handles exception in Ubuntu:

The type initializer for 'OSGeo.OGR.Ogr' threw an exception.
The type initializer for 'OSGeo.OGR.OgrPINVOKE' threw an exception.
  at OSGeo.OGR.Ogr..cctor () [0xa] in
:0
  at ExportPerformer.GenerateMif (
Adding FWTools/Bin into PATH didnt help.

Then
I've downloaded and compiled the source for gdal in GNU/Linux. 
I've compiled the swig/csharp bindings. 

Include compiled
gdal_csharp.dll,gdalconst_csharp.dll,ogr_csharp.dll,osr_csharp.dll to Xamarin 
Studio in Windows, build project under Mono/.NET platform, run "mono 
project.exe" from ubuntu and Ogr.RegisterAll(); same DllNotFoundException error:
System.TypeInitializationException: The type initializer for 'OSGeo.OGR.Ogr'
threw an exception. 
---> System.TypeInitializationException: The type initializer for
'OSGeo.OGR.OgrPINVOKE' threw an exception. 
---> System.TypeInitializationException: The type initializer for
'SWIGExceptionHelper' threw an exception. 
---> System.DllNotFoundException: ogrcsharp
  at (wrapper managed-to-native)
OSGeo.OGR.OgrPINVOKE+SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_Ogr
(OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate,
OSGeo.OGR.OgrPINVOKE/SWIGExceptionHelper/ExceptionDelegate)
  at OSGeo.OGR.OgrPINVOKE+SWIGExceptionHelper..cctor () [0x000ef] in
:0
--- End of inner exception stack trace ---
  at (wrapper managed-to-native)
System.Object:__icall_wrapper_mono_generic_class_init (intptr)
  at OSGeo.OGR.OgrPINVOKE..cctor () [0x0] in
:0
--- End of inner exception stack trace ---
  at OSGeo.OGR.Ogr..cctor () [0xa] in
:0
--- End of inner exception stack trace ---

What's wrong with that build?


Does that way to migrating from Windows to Linux will works? 
What way(csharp) to migrate this case will be correct?

Thanks.

List of files after compiling swig/csharp under linux 
 



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/csharp-gdal-fwtools-Problem-with-migrating-from-window-to-ubuntu-mono-tp5324458.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev