Proj4 Oblique Mercator giving strange results when alpha is between 90 and 270 inclusive - mercator

I have the following proj4 projection string defining an Oblique Mercator projection :
+proj=omerc +lat_0=45 +lonc=-80 +x_0=0 +y_0=0 +alpha=45 +gamma=0 +k_0=1
For my input coordinate, I was using 0, 0. When I alter the alpha angle from 45 to the range 90 to 270 inclusive, the projected point changes from the expected 80W, 45N to a point that proceeds easterly around the earth at the same latitude until the alpha is > 270, where I then get expected results again.
invproj +proj=omerc +lat_0=45 +lonc=-80 +x_0=0 +y_0=0 +alpha=45 +gamma=0 +k_0=1
0 0
80dW 45dN (this is expected)
invproj +proj=omerc +lat_0=45 +lonc=-80 +x_0=0 +y_0=0 +alpha=89 +gamma=0 +k_0=1
0 0
80dW 45dN (this is expected)
invproj +proj=omerc +lat_0=45 +lonc=-80 +x_0=0 +y_0=0 +alpha=91 +gamma=0 +k_0=1
0 0
77d10'18.699"W 45dN (this is not expected)
I'm not sure why I should be getting these different results, as a workaround, I could reverse the angle from 91 to 271, but I think I might need to also reverse the u, v in the projected system, it would be nice if Proj4 did this.
Is specifying alpha from 90-270 not supported?
Or, is there something I need to do with my parameters?
Edit: I've created an issue at Github for this at : https://github.com/OSGeo/proj.4/issues/331

It looks like there was a regression between Proj4 versions 4.7 and 4.8 that introduced a bug for this scenario, I found the following in the mailing list archives:
http://lists.maptools.org/pipermail/proj/2012-June/006331.html
Mikael Rittri wrote :
Not what I would expect. As far as I can understand, these weird results appear when alpha
is southish (in the closed interval 90 to 270). The omerc of Proj 4.7.0 did not behave this way.
This coincides with my observations. My solution was to reverse the alpha and add a pre/post processing layer that inverses the sign of the easting and northing values.

Related

How to represent/read a cube in dxf file?

Trying to open a dxf file format (actual project in C++), I could understand the basic structure of the file, but I can't manage to find how a cube is actually represented.
For a cube in CAD, I expect at least 9 values:
X Y Z position
A B C rotation
W H D size of the cube
I expect X, Y, Z, A, B and C to be in the ENTITY section,
But Looking at example files, I see many settings, the preview image (taking a significant space in the file), layouts, etc.. But nothing that I can match to how the cube is actually build.
Question:
How to represent/read a cube in a dxf file?
More info
Here is the documentation about the file format:
http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-235B22E0-A567-4CF6-92D3-38A2306D73F3
Here is an example of file with a cube (created with BricsCAD). Unfortunately, I can't embed the file, as it is too big.
The "cube" is of 20mm x 25mm x 30mm.
https://download.escain.org/example_cube_20_25_30_mm.dxf
I checked LibreCAD source-code, but it does not manage 3D models. Also, libdxfrw library is too generic (it just call the interface callback with the full Entity data).
https://github.com/LibreCAD/LibreCAD_3
https://github.com/LibreCAD/libdxfrw
This cube is embedded binary ACIS data (3DSOLID) and can not be interpreted without the libraries from Spatial Inc. For more information see my answer to another question:
How I can parse nurbs surface from dxf file? Or do you know library(for js, if exists or any other language) for parsing it?
EDIT: Find binary data of ACIS entities
Starting with R2013/AC1027 Modeler Geometry of ACIS data is stored in the section ACDSDATA in a ACDSRECORD these records have no handle, instead they have an ID. The record of your 3DSOLID starts at line 22393 and has the ID 10:
0
ACDSRECORD
90
1
2
AcDbDs::ID
280
10
320
D2 <<< handle to 3DSOLID
2
ASM_Data
280
15
94
9259 <<< size in bytes
310
41534D2042696E61... <<< binary data as multiple tags of group code 310
This is your 3DSOLD with handle D2 which starts at line 2187:
0
3DSOLID
5
D2 <<< handle of your 3DSOLID
330
1F
100
AcDbEntity
8
0
100
AcDbModelerGeometry
290
0
2
{00000000-0000-0000-0000-000000000000}
100
AcDb3dSolid
350
0
As you see there is no association from the 3DSOLID to the binary content as ACDSRECORD in the ACDSDATA section.
I have no knowledge of a table (DICTIONARY) that links this data together. The only way I know is to search all ACDSRECORD in the ACDSDATA section for links (group code 320) to ACIS objects.
FYI: In DXF versions prior to R2013 the ACIS data is stored in the entity itself as ascii text with a lousy xor "encryption". All my Knowledge about the DXF format is baked into my Python package: ezdxf.

google data studio - i get incorrect value when i do a multiplication on CPC

My problem is the value of CPC displayed after a multiplication "not correct"
Example : my CPC = 0.02 $
and i want to multiply the CPC by 10.5
i tried to do CPC * 10.5 but the result is 0.17 instead of 0.21
For information : i get data from google ads
thank you a lot in advance
The Decimal Precision in Scorecards is set to 2 places by default, thus one possibility is that the value of 0.02 in the CPC moy field is rounded from 0.0165.
Google Data Studio Report and a GIF to elaborate:

How should i format/set up my dataset/dataframe? and factor ->numeric problems

New to R and new to this forum, tried searching, hope i dont embarass myself by failing to identify previous answers.
So i got my data, and i intend to do some kind of glmm's in the end but thats far away in the future, first im going to do some simple glm/lm's to learn what im doing
first about my data:
I have data sampled from 2 "general areas" on opposite sides of the country.
in these general areas there are roughly 50 trakts placed (in a grid, random staring point)
Trakts have been revisited each year for a duration of 4 years
A tract contains 16 sample plots, i intend to work on trakt-level so i use the means of the 16 sample plots for each trakt.
2x4x50 = 400 rows (actual number is 373 rows when i have removed trakts where not enough plots could be sampled due to terrain etc)
the data in my excel file is currently divided like this:
rows = trakts
Columns= the measured variable
i got 8-10 columns i want to use
short example how the data looks now:
V1 - predictor, 4 different columns
V2 - Response variable = proportional data, 1-4 columns depending on which hypothesis i end up testing,
the glmm in the end would look something like, (V2~V1+V1+V1,(area,year))
Area Year Trakt V1 V2
A 2015 1 25.165651 0
A 2015 2 11.16894652 0.1
A 2015 3 18.231 0.16
A 2014 1 3.1222 N/A
A 2014 2 6.1651 0.98
A 2014 3 8.651 1
A 2013 1 6.16416 0.16
B 2015 1 9.12312 0.44
B 2015 2 22.2131 0.17
B 2015 3 12.213 0.76
B 2014 1 1.123132 0.66
B 2014 2 0.000 0.44
B 2014 3 5.213265 0.33
B 2013 1 2.1236 0.268
How should i get started on this?
8 different files?
Nested by trakts ( do i start nesting now or later when i'm doing glmms?)
i load my data into r through the read.tables function
If i run: sapply(dataframe,class)
V1 and V2 are factors, everything else integer
if i run sapply(dataframe,mode)
everything is numeric
so finally to my actual problems, i have been trying to do normality tests (only trid shapiro so far) but i keep getting errors that imply my data is not numeric
also, when i run a normality test, do i only run one column and evaluate it before moving on to the next column or should i run several columns? the entire dataset?
should i in my case run independent normality tests for each of my areas and year?
hope it didnt end up to cluttered
best regards

I tried all ways, but still my area is calculated wrongly in Postgis

I created a very simple polygon in the middle of Germany to demonstrate my problem.
You can visualize it in geojsonlint using the following GeoJSON
{"type":"Polygon","coordinates":[[
[10.439844131469727,51.17460781257472],
[10.430574417114258,51.1753073564544],
[10.429565906524658,51.17179607723465],
[10.438792705535889,51.170706315523866],
[10.439372062683105,51.17267055874809],
[10.43975830078125,51.17439256616884],
[10.439844131469727,51.17460781257472]]]G}
When calculating the surface with online tools (e.g. http://www.daftlogic.com/projects-google-maps-area-calculator-tool.htm, but I tried several),
I get the following numbers (these are based on a similar drawing of the polygon, but not the exact same one, as I couldn't copy it over to these tools):
276583.39 m²
0.28 km²
68.35 acres
27.66 hectares
2977118.86 feet²
0.08 square nautical miles
Now I want to calculate these areas using POSTGIS, but I always get wrong and not matching numbers.
First I started without transformation using the examples given here:
http://postgis.net/docs/ST_Area.html
SELECT ST_Area(the_geom) As sqft, ST_Area(the_geom)*POWER(0.3048,2) As sqm
FROM (SELECT ST_GeomFromText('
POLYGON ((51.17460781257472 10.439844131469727,
51.1753073564544 10.430574417114258,
51.17179607723465 10.429565906524658,
51.170706315523866 10.438792705535889,
51.17267055874809 0.439372062683105,
51.17439256616884 10.43975830078125,
51.17460781257472 10.439844131469727))',4326) ) As foo(the_geom);
--> sqft = 3.52643124351653e-05 and sqm = 3.27616182873666e-06
How can I interprete these numbers?
Then I tried to transform it to WGS 84 / UTM zone 33N 32633
SELECT ST_Area(the_geom) As sqft, ST_Area(the_geom)*POWER(0.3048,2) As sqm
FROM (SELECT ST_Transform(ST_GeomFromText('
POLYGON ((51.174661624019286 10.440187454223633,
51.17067940750161 10.438899993896484,
51.17197097486416 10.429544448852539,
51.17536116708255 10.430488586425781,
51.174661624019286 10.440187454223633))',4326),32633) ) As foo(the_geom);
--> sqft = 662918.939349234 and sqm = 61587.1847391195
But even these numbers don't come close.
The coordinates of the polygon were accidentally loaded as lat,lon instead of lon, lat.
http://postgis.net/2013/08/18/tip_lon_lat
says
In spatial databases spatial coordinates are in x = longitude, and y = latitude
I converted the coordinates into EPSG: 31467, see epsg:31467 which is projected to meters and applies to the area of Germany covered by your geometry.
select st_area(st_transform(st_setsrid(st_geomfromtext('POLYGON((10.439844131469727
51.17460781257472,10.430574417114258 51.1753073564544,10.429565906524658
51.17179607723465,10.438792705535889 51.170706315523866, 10.439372062683105
51.17267055874809, 10.43975830078125 51.17439256616884, 10.439844131469727
51.17460781257472))'),4326),31467));
and got the answer: 274442.27 m2 which is within 0.007% of your original answer.
Measurements are usually more accurate in projected coordinate systems that use a geoid appropriate to that region. If you run this query on the spatial reference system table in Postgis for that projection:
select * from spatial_ref_sys where srid=31467;
you will see some more details, such as the fact that it uses the Bessel 1841 spheroid.
EDIT: your original geojson has coordinates in x/y, but for some reason you flipped them when putting them into Postgis.

Formatting numbers according to input precision

I have an SSRS report pulling data in from a column of type DECIMAL(9,3). I want to display these values to the number of decimal places used to enter the data into the system.
For example:
Data Output
------- -------
123.456 123.456
123.450 123.45
123.400 123.4
123.006 123.006
120.000 123
120.000 120
100.000 100
I know you can format numeric data to a specific number of decimal places using the Format property for the column (e.g. N3 for 3dp), and I know that in C# the format string "{0:###}" would achieve the desired result.
I feel like it should be easy to do, but so far I've not found the right syntax to combine the two concepts in SSRS. What am I missing?
You can use the 0.### mask. In this case, it will produce the following results:
0.510 -> 0.51
6.581 -> 6.581
9.10 -> 9.1
Just checked it, works on SSRS 2008/2008 R2.

Resources